Question about H2 and chunked encoding

Hi guys,

while implementing H2->H1 gateway support in haproxy, I'm facing a
situation in which I'm not sure about the most interoperable solution.

Let's say I'm receiving this response message from a H1 server that I
need to re-encode into H2 :

    HTTP/1.1 200 OK\r\n
    Transfer-encoding: chunked\r\n
    Content-Type: text-html\r\n

Please note that there is not any trailers yet nor is there the trailing
CRLF. At this point I can emit a HEADERS frame containing :


and a DATA frame of size 5 containing "Hello".

But given that I have not yet seen what follows the 0\r\n, I can't yet
put the ES flag on the DATA frame. So once I get the end, either I'll
have to send a HEADERS frame containing the trailers, or I'll simply have
to close the stream.

My concern is what's the safest / most interoperable way to close the stream
at this point ? Should I send an empty DATA frame of size zero with ES bit
set or should I send a HEADERS frame of size zero with ES bit set ?

I tend to think that DATA+ES looks cleaner (ie: can be seen as last bit of
the DATA frame), but given that we're possibly expecting some trailers here,
it would also make sense to consider sending an empty HEADERS frame.

I'd like to avoid doing something that some clients may choke on, and I
suspect that empty HEADERS may not be that good.

Any enlightenment would be much appreciated :-)


Received on Friday, 4 August 2017 04:54:41 UTC