avoiding chunked encoding of HTTP/1.1 response
Asked Answered
E

1

7

I want to avoid ever getting chunked encoded HTTP server response from (conforming) HTTP server. I am reading RFC 2616 section "14.39 TE" and it seems to me that I could avoid it by specifying TE: chunked;q=0. If I cannot avoid the chunked encoding, I want do avoid the trailers. Will specifying TE: trailers;q=0 work?

Estafette answered 11/8, 2013 at 17:1 Comment(2)
The title was: "avoiding chunked encoding of HTTP/1.1 response" but you wrote: "I want to avoid ever getting chunked encoded HTTP server response from (conforming) HTTP server" So if you are allowed to send a HTTP 1.0 GET request instead of 1.1, transfers will not be chunked (no chunk size dirtying your buffers)Stabler
I do not remember the exact situation any more. I vaguely remember I needed HTTP/1.1 for some reason in the request and I wanted to avoid the chunked encoding because it was hard to distinguish trailing headers of the chunked encoding from headers of new requests in the libcurl callbacks I was using.Estafette
H
10

From rfc2616 - Hypertext Transfer Protocol -- HTTP/1.1 in section 3.6.1 Chunked Transfer Coding:

All HTTP/1.1 applications MUST be able to receive and decode the "chunked" transfer-coding, and MUST ignore chunk-extension extensions they do not understand.

This is still the case in the updated RFC 7230 - Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing in section 4.1. Chunked Transfer Coding although in a slightly different wording:

A recipient MUST be able to parse and decode the chunked transfer coding.

So if you want to be conform to HTTP/1.1, you will have to accept chunked encoding.


##Update##

As for the trailers: I think if you don't send a TE header field in your request, a conforming server shouldn't send you any trailers. If it still sends trailers you are probably save to ignore them (again section 3.6.1):

A server using chunked transfer-coding in a response MUST NOT use the trailer for any header fields unless at least one of the following is true:

a) the request included a TE header field that indicates "trailers" is acceptable in the transfer-coding of the response, as described in section 14.39; or,

b) the server is the origin server for the response, the trailer fields consist entirely of optional metadata, and the recipient could use the message (in a manner acceptable to the origin server) without receiving this metadata. In other words, the origin server is willing to accept the possibility that the trailer fields might be silently discarded along the path to the client.

Haigh answered 11/8, 2013 at 17:6 Comment(3)
Thanks. I hoped I was not reading the RFC right and that the q=0 could override this. :)Estafette
@Estafette You're welcome. As for the trailers: just don't send a TE header field or ignore the trailers. (See my update...)Haigh
Unfortunately if you have to write code to ignore trailers it is almost as easy as to handle them. And i whish there were a http test case server because i still have to look for some server which sends trailers or more exotic any chunk parameters.Alongshore

© 2022 - 2024 — McMap. All rights reserved.