Skip to content

Commit

Permalink
COCOON-2358 Inconsistent Content-Length header for HEAD requests
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X@1809196 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cdamioli committed Sep 21, 2017
1 parent 30f300c commit 1708f42
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/java/org/apache/cocoon/environment/http/HttpEnvironment.java
Expand Up @@ -198,6 +198,19 @@ public String getContentType() {
public void setContentLength(int length) {
this.response.setContentLength(length);
}

public void commitResponse() throws IOException
{
if (this.secureOutputStream != null) {
// COCOOON-2358: for an HEAD request, it is wrong to set the content length to the actual response body size
if (this.secureOutputStream.isResettable() && !request.getMethod().equals("HEAD")) {
this.setContentLength(this.secureOutputStream.getCount());
}
this.secureOutputStream.flush();
} else if (this.outputStream != null) {
this.outputStream.flush();
}
}

/**
* Check if the response has been modified since the same
Expand Down

0 comments on commit 1708f42

Please sign in to comment.