14

Is it possible for a HTTP 1.1 client to set a header value that indicates the responses to requests should not be chunked? Or is the only way to prevent this, is to send a HTTP 1.0 request? I've tried googling around, but all I can find is ways to disable chunked transfers on HTTP 1.1 servers, so I am guessing it is not possible on a client, but I thought I'd ask anyways.

Matt
  • 774
  • 1
  • 10
  • 28

2 Answers2

10

In HTTP (starting with HTTP/1.1), recipients MUST support chunked encoding. See http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p1-messaging-26.html#rfc.section.4.1.p.4.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98
  • It seems that you are correct. Although after reading it I did notice that was a draft of the standard. In case anyone else is interested, here is the finalized standard ftp://www.ietf.org/rfc/rfc2616.txt see the end of section 3.6.1 – Matt May 21 '14 at 06:08
  • 1
    RFC 2616 is the old one. The draft is the current spec and will be published as RFC shortly. – Julian Reschke May 21 '14 at 06:27
  • Looks like you're right again... if it is approved. Would you mind editing your answer so it says "In HTTP 1.1, recipients...". Chunked encoding isnt part of HTTP 1.0 and earlier. I tried, but for whatever reason it seems as if my edit was reverted. – Matt May 21 '14 at 06:53
  • Hmm... it didnt show as approved before, in fact it didnt say it was waiting for peer review at all anymore when I made my previous comment. A edit does appear now, but it isnt mine. Anyways thanks again for your help. – Matt May 21 '14 at 06:59
  • When I said "it is approved" I was referring to the specification. See: https://datatracker.ietf.org/doc/draft-ietf-httpbis-p1-messaging/ – Julian Reschke May 21 '14 at 07:11
  • Note that chunked transfer is deprecated for HTTP/2. – Mark McKenna Apr 04 '18 at 19:47
  • @MarkMcKenna - it's not "deprecated", it simply does not exist anymore – Julian Reschke Apr 07 '18 at 16:30
-2

To get Content-Length in bytes instead of chunked inside the response with HTTP 1.1, you have to set Content-Length header and its size (long or int) based on the file you are expecting inside the response. long will be good so it can take care small as well as big file size. response will be HttpServletResponse. response.addHeader(Content-Length, Long.toString()); Thanks,

  • 2
    This may be correct from the server perspective (though a little Java specific) but the question is about requesting this from the client side. – thomasrutter Jan 01 '18 at 23:35