Skip to content

Commit

Permalink
Merge branch '2.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
bclozel committed Apr 14, 2020
2 parents 1604cb2 + 49bbcce commit 939bb87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import org.springframework.boot.web.server.Compression;
import org.springframework.http.HttpHeaders;
import org.springframework.util.InvalidMimeTypeException;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;

Expand Down Expand Up @@ -90,11 +91,17 @@ private static class CompressibleMimeTypePredicate implements Predicate {
public boolean resolve(HttpServerExchange value) {
String contentType = value.getResponseHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
if (contentType != null) {
for (MimeType mimeType : this.mimeTypes) {
if (mimeType.isCompatibleWith(MimeTypeUtils.parseMimeType(contentType))) {
return true;
try {
MimeType parsed = MimeTypeUtils.parseMimeType(contentType);
for (MimeType mimeType : this.mimeTypes) {
if (mimeType.isCompatibleWith(parsed)) {
return true;
}
}
}
catch (InvalidMimeTypeException ex) {
return false;
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,12 @@ protected WebClient prepareCompressionTest(Compression compression, String respo
}

protected void assertResponseIsCompressed(ResponseEntity<Void> response) {
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getHeaders().getFirst("X-Test-Compressed")).isEqualTo("true");
}

protected void assertResponseIsNotCompressed(ResponseEntity<Void> response) {
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getHeaders().keySet()).doesNotContain("X-Test-Compressed");
}

Expand Down

0 comments on commit 939bb87

Please sign in to comment.