BUG/MEDIUM: h2: implement missing support for chunked encoded uploads
authorWilly Tarreau <w@1wt.eu>
Wed, 25 Apr 2018 18:44:22 +0000 (20:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 26 Apr 2018 08:20:44 +0000 (10:20 +0200)
commiteba10f24b7da27cde60d2db24aeb1147e1657579
tree2395540050639676504f374d530e27cce1a2f3aa
parent174b06a572ef141f15d8b7ea64eb6b34ec4c9af1
BUG/MEDIUM: h2: implement missing support for chunked encoded uploads

Upload requests not carrying a content-length nor tunnelling data must
be sent chunked-encoded over HTTP/1. The code was planned but for some
reason forgotten during the implementation, leading to such payloads to
be sent as tunnelled data.

Browsers always emit a content length in uploads so this problem doesn't
happen for most sites. However some applications may send data frames
after a request without indicating it earlier.

The only way to detect that a client will need to send data is that the
HEADERS frame doesn't hold the ES bit. In this case it's wise to look
for the content-length header. If it's not there, either we're in tunnel
(CONNECT method) or chunked-encoding (other methods).

This patch implements this.

The following request is sent using content-length :

    curl --http2 -sk https://127.0.0.1:4443/s2 -XPOST -T /large/file

and these ones using chunked-encoding :

    curl --http2 -sk https://127.0.0.1:4443/s2 -XPUT -T /large/file
    curl --http2 -sk https://127.0.0.1:4443/s2 -XPUT -T - < /dev/urandom

Thanks to Robert Samuel Newson for raising this issue with details.
This fix must be backported to 1.8.
src/h2.c
src/mux_h2.c