Ignore header case to determine if content is gzipped (#143)
Summary: This PR updates the Network plugin's response parser to ignore the case of the `Content-Encoding` header in the response. This was preventing responses that are gzipped from being uncompressed. I tested this with gzipped responses through the OkHttp interceptor on Android. This could potentially address #79 as I was experiencing that issue before this change.  Pull Request resolved: https://github.com/facebook/Sonar/pull/143 Differential Revision: D8780509 Pulled By: danielbuechele fbshipit-source-id: 1a2d86226a8a0204ff43eb5f9394a56c04fd2d8d
This commit is contained in:
committed by
Facebook Github Bot
parent
dad05de943
commit
c8c2cfa16f
@@ -56,11 +56,8 @@ function decodeBody(container: Request | Response): string {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
const b64Decoded = atob(container.data);
|
const b64Decoded = atob(container.data);
|
||||||
const encodingHeader = container.headers.find(
|
|
||||||
header => header.key === 'Content-Encoding',
|
|
||||||
);
|
|
||||||
|
|
||||||
return encodingHeader && encodingHeader.value === 'gzip'
|
return getHeaderValue(container.headers, 'Content-Encoding') === 'gzip'
|
||||||
? decompress(b64Decoded)
|
? decompress(b64Decoded)
|
||||||
: b64Decoded;
|
: b64Decoded;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ const COLUMNS = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getHeaderValue(headers: Array<Header>, key: string) {
|
export function getHeaderValue(headers: Array<Header>, key: string): string {
|
||||||
for (const header of headers) {
|
for (const header of headers) {
|
||||||
if (header.key.toLowerCase() === key.toLowerCase()) {
|
if (header.key.toLowerCase() === key.toLowerCase()) {
|
||||||
return header.value;
|
return header.value;
|
||||||
|
|||||||
Reference in New Issue
Block a user