Skip to content

Commit

Permalink
Issue googleapis#842 - HttpResponse GZip content encoding equality ch…
Browse files Browse the repository at this point in the history
…ange
  • Loading branch information
egsavage committed Oct 14, 2019
1 parent ea09fd5 commit 5f39135
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -80,6 +80,12 @@ public final class HttpResponse {
/** Whether {@link #getContent()} should return raw input stream. */
private final boolean returnRawInputStream;

/** Content encoding for GZip */
private static final String CONTENT_ENCODING_GZIP = "gzip";

/** Content encoding for GZip HTTP 1.1 */
private static final String CONTENT_ENCODING_XGZIP = "x-gzip";

/**
* Determines the limit to the content size that will be logged during {@link #getContent()}.
*
Expand Down Expand Up @@ -330,7 +336,8 @@ public InputStream getContent() throws IOException {
String contentEncoding = this.contentEncoding;
if (!returnRawInputStream
&& contentEncoding != null
&& contentEncoding.contains("gzip")) {
&& (CONTENT_ENCODING_GZIP.equalsIgnoreCase(contentEncoding.trim())
|| CONTENT_ENCODING_XGZIP.equalsIgnoreCase(contentEncoding.trim()))) {
lowLevelResponseContent = new GZIPInputStream(lowLevelResponseContent);
}
// logging (wrap content with LoggingInputStream)
Expand Down

0 comments on commit 5f39135

Please sign in to comment.