问题
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.
回答1:
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.
回答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,
来源:https://stackoverflow.com/questions/23773536/http-1-1-can-a-client-request-that-transfers-not-be-chunked