Skip to content

Commit 626218f

Browse files
committed
Merge pull request #359 from ParsePlatform/wangmengyan.remove_content_encoding_header_when_auto_unzip_response
Remove Content-Encoding header when we auto unzip the response steram
2 parents 033d642 + 7978696 commit 626218f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Parse/src/main/java/com/parse/ParseApacheHttpClient.java

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
*/
5353
@SuppressWarnings("deprecation")
5454
/** package */ class ParseApacheHttpClient extends ParseHttpClient<HttpUriRequest, HttpResponse> {
55+
56+
private static final String CONTENT_ENCODING_HEADER = "Content-Encoding";
57+
5558
private DefaultHttpClient apacheClient;
5659

5760
public ParseApacheHttpClient(int socketOperationTimeout, SSLSessionCache sslSessionCache) {
@@ -149,6 +152,10 @@ public ParseApacheHttpClient(int socketOperationTimeout, SSLSessionCache sslSess
149152
for (Header header : apacheResponse.getAllHeaders()) {
150153
headers.put(header.getName(), header.getValue());
151154
}
155+
// If we auto unzip the response stream, we should remove the content-encoding header
156+
if (!disableHttpLibraryAutoDecompress()) {
157+
headers.remove(CONTENT_ENCODING_HEADER);
158+
}
152159

153160
// Content type
154161
String contentType = null;

Parse/src/test/java/com/parse/ParseHttpClientTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ private void doSingleParseHttpClientExecuteWithGzipResponse(
202202

203203
assertEquals("gzip", recordedHeaders.get("Accept-Encoding"));
204204

205+
// Verify we do not have Content-Encoding header
206+
assertNull(parseResponse.getHeader("Content-Encoding"));
207+
205208
// Verify response body
206209
byte[] content = ParseIOUtils.toByteArray(parseResponse.getContent());
207210
assertArrayEquals(responseContent.getBytes(), content);

0 commit comments

Comments
 (0)