netty/netty — pull request #2383 by died103times (2014-04-13 05:51:14+00:00)
Title: Sending 100 Continue response for request with Expect: 100-continue

Netty version: 5.0.0.Alpha2

Context:
Working on a project that uses LittleProxy (see http://www.littleshoot.org/littleproxy/ and https://github.com/adamfisk/LittleProxy, which is in turn based on Netty. By default LittleProxy creates a pipeline where all inbound handlers come first, then all outbound handlers, e.g.:
* BytesReadMonitor
* HttpRequestDecoder
* RequestReadMonitor
* HttpObjectAggregator
* ResponseWrittenMonitor
* HttpResponseEncoder
* BytesWrittenMonitor

This works fine for both incoming and outgoing messages. Except the case of "Expect: 100-continue" PUT/POST request. The "Expect: 100-continue" request is processed in HttpObjectAggregator handler, and to send back the "100 Continue" response it searches for outbound handler backwards from current element (i.e. from HttpObjectAggregator), not from end of the list, as done for all other responses. The search falls through the beginning of the pipeline, and causes an exception and dropped client connection.

I believe, HttpObjectAggregator should follow the same handler lookup procedure for "100 Continue" response as for any other responses - i.e. check all outbound handlers backward from the end of pipeline.

I'm not listing the steps two reproduce the issue - that would involve setting up LittleProxy (or equivalent proxy-like service) on top of Netty, which is tedious. For minimal Netty-specific use case see the added unit test.

JDK version, Operating system, Network configuration - not relevant.