RFR: 8283544: HttpClient GET method adds Content-Length: 0 header [v6]
Daniel Fuchs
dfuchs at openjdk.java.net
Fri May 6 14:02:37 UTC 2022
On Fri, 6 May 2022 10:39:38 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> Conor Cleary has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8283544: Improved logging, drain input stream
>
> src/java.net.http/share/classes/jdk/internal/net/http/Http1Request.java line 311:
>
>> 309: streaming = true;
>> 310: systemHeadersBuilder.setHeader("Transfer-encoding", "chunked");
>> 311: }
>
> With that - and if I'm not mistaken, lines 294-299 can be removed now.
hmmm... some parts seem to be missing now. I believe what we need is:
// Absence of a requestPublisher indicates a request with no body
// (GET, HEAD, DELETE), in which case we don't explicitly set any
// Content-Length header
if (requestPublisher != null) {
contentLength = requestPublisher.contentLength();
if (contentLength == 0) {
systemHeadersBuilder.setHeader("Content-Length", "0");
} else if (contentLength > 0) {
systemHeadersBuilder.setHeader("Content-Length", Long.toString(contentLength));
streaming = false;
} else {
streaming = true;
systemHeadersBuilder.setHeader("Transfer-encoding", "chunked");
}
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/8017
More information about the net-dev
mailing list