Skip to content

Commit bebe589

Browse files
committed
allow custom Content-Length for HEAD method
1 parent e028535 commit bebe589

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

containers/netty-http/src/main/java/org/glassfish/jersey/netty/httpserver/NettyResponseWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -105,7 +105,7 @@ public synchronized OutputStream writeResponseStatusAndHeaders(long contentLengt
105105

106106
if (contentLength == -1) {
107107
HttpUtil.setTransferEncodingChunked(response, true);
108-
} else {
108+
} else if (req.method() != HttpMethod.HEAD || !response.headers().contains(HttpHeaderNames.CONTENT_LENGTH)) {
109109
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, contentLength);
110110
}
111111

0 commit comments

Comments
 (0)