1

I instantiated a netty 4 (using netty-all-4.0.9.jar) service and initialized the channel by adding 3 ChannelHandler objects:

pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("handler", new MyHandler());

When testing w/ curl HTTP PUTing a file to my server and I found MyHandler.channelRead is not called immediately for requests with Expect: 100-continue header is sent (curl is waiting for the server to reply with 100 Continue. This means my handler is not able to reply with a HTTP/1.1 100 Continue response to tell the client (curl) to initiate the actual upload of the file immediate.

Interestingly further debugging this issue with telnet shows that a channelRead is called right once the actual body is being uploaded (right after the first byte is received).

Any hints on how to handle PUT requests with 'Expect: 100-continue' header properly to trigger 100 Continue response immediately?

phrinx
  • 13
  • 3

1 Answers1

1

Examples coming with netty (e.g. HttpHelloWorldServerHandler.java) have the following code in the channelRead() method:

if (is100ContinueExpected(req)) {
     ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE));
}
Igor Alelekov
  • 311
  • 2
  • 4
  • I appears the helloworld handler in the example works fine. I investigated further and found that I had a HttpContentDecompressor in the channel pipeline. Removing it solved my problem. Thanks for the hint with the helloworld handler - working backward from here pointed me the root cause (even though I'm not sure why it behaves like this - you can easily reproduce thgis behavior by adding 'p.addLast("deflater", new HttpContentDecompressor()' to the HttpHelloWorldServerInitializer class. – phrinx Oct 03 '13 at 19:34