RE: Question about H2 and chunked encoding

I'll second the empty DATA frame.  We do that pretty routinely and haven't hit any notable issues with it.

-----Original Message-----
From: Martin Thomson [mailto:martin.thomson@gmail.com] 
Sent: Thursday, August 3, 2017 10:01 PM
To: Willy Tarreau <w@1wt.eu>
Cc: HTTP Working Group <ietf-http-wg@w3.org>
Subject: Re: Question about H2 and chunked encoding

If you don't actually have trailers, I would send an empty DATA + ES.
That is (to my knowledge) perfectly interoperable.

I'll let others speak about how well tested an empty HEADERS is, but there's an important difference in the semantics if you use that.  As soon as you send HEADERS with ES, you declare the presence of trailers.  That they are empty is potentially confusing.

On 4 August 2017 at 14:54, Willy Tarreau <w@1wt.eu> wrote:
> 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
>     \r\n
>     0005\r\n
>     Hello\r\n
>     0\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 :
>
>    :status=200
>    content-type=text-html
>
> 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 :-)
>
> thanks,
> Willy
>

Received on Friday, 4 August 2017 06:32:36 UTC