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?
- 2The 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)Chixul– Chixul2014-07-27 11:38:45 +00:00Commented Jul 27, 2014 at 11:38
- 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.wilx– wilx2014-07-27 11:46:18 +00:00Commented Jul 27, 2014 at 11:46
1 Answer
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.
3 Comments
q=0 could override this. :)TE header field or ignore the trailers. (See my update...)