tempesta icon indicating copy to clipboard operation
tempesta copied to clipboard

Remove chunked encoding on h1 -> h2 response transformation

Open vankoven opened this issue 6 years ago • 2 comments

Scope

RFC 7540 Section 8.1 :

HTTP/2 uses DATA frames to carry message payloads. The chunked transfer encoding defined in Section 4.1 of [RFC7230] MUST NOT be used in HTTP/2.

A response in chunked encoding must drop the chunked encoding: remove Transfer-Encoding: chunked header, remove chunks descriptors, move chunked trailer headers part to separate HEADERS frame.

Depending on message buffering (#498), a message can be entirely buffered or streamed by parts. For fully buffered messages it's OK to merge trailer headers with main headers and avoid adding extra HEADERS frame after DATA one. It reduces some work for us.

From Examples:

HTTP/1.1 200 OK                  HEADERS
  Content-Type: image/jpeg   ==>     - END_STREAM
  Transfer-Encoding: chunked         + END_HEADERS
  Trailer: Foo                         :status = 200
                                       content-length = 123
  123                                  content-type = image/jpeg
  {binary data}                        trailer = Foo
  0
  Foo: bar                         DATA
                                     - END_STREAM
                                   {binary data}

                                   HEADERS
                                     + END_STREAM
                                     + END_HEADERS
                                       foo = bar

Testing

Send a response with chunked payload from a backend and forward it to h2 client. Client must receive message without chunked encoding. Also test case with chunked headers part.

vankoven avatar Jan 10 '20 07:01 vankoven

The draft pull request https://github.com/tempesta-tech/tempesta/pull/1418 , tests https://github.com/tempesta-tech/tempesta-test/pull/164

krizhanovsky avatar Dec 05 '21 23:12 krizhanovsky

@const-t hit the issue on fastcgi+php, i.e. installations like WordPress, so the bug is crucial

krizhanovsky avatar Jun 23 '22 18:06 krizhanovsky