HEAD response no longer sends response body

Affects issues:
- Fixed #1431
This commit is contained in:
Risto Lahtela 2020-05-13 10:48:03 +03:00
parent bc7e84677f
commit 788e6dc195

View File

@ -45,13 +45,24 @@ public class ResponseSender {
public void send() throws IOException { public void send() throws IOException {
setResponseHeaders(); setResponseHeaders();
if ("bytes".equalsIgnoreCase(response.getHeaders().get("Accept-Ranges"))) { if ("HEAD".equals(exchange.getRequestMethod())) {
sendHeadResponse();
} else if ("bytes".equalsIgnoreCase(response.getHeaders().get("Accept-Ranges"))) {
sendRawBytes(); sendRawBytes();
} else { } else {
sendCompressed(); sendCompressed();
} }
} }
public void sendHeadResponse() throws IOException {
try {
exchange.getResponseHeaders().remove("Content-Length");
beginSend();
} finally {
exchange.getRequestBody().close();
}
}
private void setResponseHeaders() { private void setResponseHeaders() {
Headers headers = exchange.getResponseHeaders(); Headers headers = exchange.getResponseHeaders();