undertow-io/undertow — pull request #144 by ialbors (2013-12-11 22:49:11+00:00)
Title: Avoid ChunkedStreamSinkConduit on 100-continue

Ok. This is a dirty workaround for an issue when receiving a request with both "Expect: 100-continue" and "Transfer-Encoding: chunked" headers. I hope it will, at least, make more clear what is the issue but I'm sure there is a better fix.

Plese, be indulgent if the nonsense I'm going to explain now sounds like crap: I don't think I fully understand all the code yet.

Like I said, when receiving a request with those headers, the first response (out of band) is the "100 continue". Because of the presence of the "Transfer-Encoding: chunked", it will use a ChunkedStreamSinkConduit, and it will close its channel after writing the out of band response.

For the actual response (in band) it will try to use the same ChunkedStreamSinkConduit but, closed as it is, it won't write anything.

So, I removed the "Transfer Encoding" header before sending out of band. And put it back again right after.

Does it make any sense?