On Thu, 31 Mar 2022 08:42:35 GMT, Daniel Fuchs <[email protected]> wrote:
>> RFC 7230 section 3.3.2 says: >> "A user agent SHOULD NOT send a >> Content-Length header field when the request message does not contain >> a payload body and the method semantics do not anticipate such a >> body." >> I don't think the DELETE method anticipates a a request body. So, it >> shouldn't have a Content-Length header either IMO. Same for HEAD also. > > Thanks @Michael-Mc-Mahon Michael. Let's do as @djelinski Daniel suggests then > - and only set Content-Length if requestPublisher != null (that is remove the > `|| !"GET".equals(request.method())` part of the if). The test would need to > be extended to test DELETE and HEAD but that shouldn't be too difficult. FWIW, the relevant text now is in https://www.rfc-editor.org/rfc/rfc9110.html#section-8.6: > A user agent SHOULD send Content-Length in a request when the method defines > a meaning for enclosed content and it is not sending Transfer-Encoding. For > example, a user agent normally sends Content-Length in a POST request even > when the value is 0 (indicating empty content). A user agent SHOULD NOT send > a Content-Length header field when the request message does not contain > content and the method semantics do not anticipate such data. ------------- PR: https://git.openjdk.org/jdk/pull/8017
