How to send content using Netty Http Client?
I'm using Netty Http client to send requests to a http server.
I am re-using the channel and keeping the connection live to reuse it between requests.
My problem is that although the get method works perfectly, I can' manage to send content in put or post. Following is the code I am using but in my server the http request input stream is empty.
Any ideas?
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.valueOf(method), uri.t开发者_Python百科oASCIIString());
if (payLoad != null) {
request.setContent(ChannelBuffers.wrappedBuffer(payLoad));
}
Note: payload is a bytearray.
Thanks,
Yair
Since your GET requests work fine, I assume that you write it to channel correctly.
Therefore I would focus on http post:
From http request point of view, you have to specify few more headers in your request. At the very least have a look at Host, Connection, Accept-Encoding, Content-Type and Content-Length.
精彩评论