YaOg
YaOg

Reputation: 1768

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.toASCIIString());
    if (payLoad != null) {
        request.setContent(ChannelBuffers.wrappedBuffer(payLoad));
    }

Note: payload is a bytearray.

Thanks,

Yair

Upvotes: 0

Views: 2518

Answers (1)

diginoise
diginoise

Reputation: 7630

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.

Upvotes: 2

Related Questions