简体   繁体   English

具有http multipart formdata POST方法的Java套接字

[英]Java socket with http multipart formdata POST method

I'm using java and I'm looking for solution to get respond from website. 我正在使用Java,并且正在寻找解决方案以从网站获得响应。 The problem is i need to create a handshake with server for about 30 sec and then send header and body to finish request.This also a multipart/formdata POST method. 问题是我需要与服务器建立握手约30秒,然后发送标头和正文以完成请求。这也是multipart / formdata POST方法。 can anyone suggest me where to find tutorial or some example of code? 谁能建议我在哪里可以找到教程或一些代码示例? Thank you. 谢谢。

You can surely work lower-level (TCP-level) blocking-style as in http://examples.javacodegeeks.com/core-java/net/socket/send-http-post-request-with-socket/ 您一定可以像在http://examples.javacodegeeks.com/core-java/net/socket/send-http-post-request-with-socket/中那样使用较低级别(TCP级别)的阻塞样式。

I'm confident there should be a way to do that in Netty, you could try having a look at How to send a request with POST parameters in Netty? 我相信在Netty中应该有一种方法可以做到这一点,您可以尝试看看如何在Netty中发送带有POST参数的请求? .

I couldn't find other Java libraries that would allow you to wait before sending headers, but many (including JDK's URLConnection) will allow you to pre-configure headers and then stream the body. 我找不到其他允许您在发送标头之前等待的Java库,但是许多Java库(包括JDK的URLConnection)将允许您预先配置标头,然后流式处理正文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM