Skip to content

Commit

Permalink
Relocate the useCompression check and apply parts back to back.
Browse files Browse the repository at this point in the history
  • Loading branch information
shin-mallang authored and markt-asf committed Sep 14, 2023
1 parent 3cf8b95 commit e47d0c4
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions java/org/apache/coyote/http11/Http11Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -904,12 +904,6 @@ protected final void prepareResponse() throws IOException {
prepareSendfile(outputFilters);
}

// Check for compression
boolean useCompression = false;
if (entityBody && sendfileData == null) {
useCompression = protocol.useCompression(request, response);
}

MimeHeaders headers = response.getMimeHeaders();
// A SC_NO_CONTENT response may include entity headers
if (entityBody || statusCode == HttpServletResponse.SC_NO_CONTENT) {
Expand Down Expand Up @@ -946,8 +940,11 @@ protected final void prepareResponse() throws IOException {
}
}

if (useCompression) {
outputBuffer.addActiveFilter(outputFilters[Constants.GZIP_FILTER]);
// Check for compression
if (entityBody && sendfileData == null) {
if (protocol.useCompression(request, response)) {
outputBuffer.addActiveFilter(outputFilters[Constants.GZIP_FILTER]);
}
}

// Add date header unless application has already set one (e.g. in a
Expand Down

0 comments on commit e47d0c4

Please sign in to comment.