net-http icon indicating copy to clipboard operation
net-http copied to clipboard

Feature Request: Support Http trailers in chunked transfer

Open alextwoods opened this issue 4 years ago • 2 comments

Trailers in chunked transfer are described by rfc3230-section 4.1. Net/http does not support setting trailers nor is there a way for users to implement chunked trailers on top of net/http. The grammar is (combining section 4.1 and 4.1.2):

chunked-body   = *chunk
                      last-chunk
                      trailer-part
                      CRLF

     chunk          = chunk-size [ chunk-ext ] CRLF
                      chunk-data CRLF
     chunk-size     = 1*HEXDIG
     last-chunk     = 1*("0") [ chunk-ext ] CRLF

     chunk-data     = 1*OCTET ; a sequence of chunk-size octets
     trailer-part   = *( header-field CRLF )

When a body_stream is set and the transfer-encoding is chunked, GenericRequest#send_request_with_body_stream creates a Chunker . The Chunker correctly follows the rfc in writing out the chunks and writing the last-chunk as "0\r\n\r\n". However, there are no hooks or support for writing the trailer-part.

alextwoods avatar Aug 17 '21 19:08 alextwoods

@hsbt Any input on this? Would a pull request be welcomed?

mullermp avatar Sep 30 '21 18:09 mullermp

Would the maintainers accept an implementation PR?

Velfi avatar Aug 21 '24 16:08 Velfi