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 PUT
ing 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?
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));
}