mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-07-29 00:59:10 +00:00
do not unzip the response body when it's empty, such as 304
also remove the delete operatoin for 'accept-encoding' in the test utils, since AnyProxy will not remove the header now
This commit is contained in:
@@ -93,11 +93,12 @@ function fetchRemoteResponse(protocol, options, reqData, config) {
|
||||
fulfill(resDataStream);
|
||||
} else {
|
||||
const serverResData = Buffer.concat(resDataChunks);
|
||||
const originContentLen = util.getByteSize(serverResData);
|
||||
// set origin content length into header
|
||||
resHeader['x-anyproxy-origin-content-length'] = originContentLen;
|
||||
|
||||
// put origin content length into header
|
||||
resHeader['x-anyproxy-origin-content-length'] = util.getByteSize(serverResData);
|
||||
|
||||
if (ifServerGzipped) {
|
||||
// only do unzip when there is res data
|
||||
if (ifServerGzipped && originContentLen) {
|
||||
zlib.gunzip(serverResData, (err, buff) => { // TODO test case to cover
|
||||
if (err) {
|
||||
rejectParsing(err);
|
||||
@@ -105,7 +106,7 @@ function fetchRemoteResponse(protocol, options, reqData, config) {
|
||||
fulfill(buff);
|
||||
}
|
||||
});
|
||||
} else if (isServerDeflated) {
|
||||
} else if (isServerDeflated && originContentLen) {
|
||||
zlib.inflateRaw(serverResData, (err, buff) => { // TODO test case to cover
|
||||
if (err) {
|
||||
rejectParsing(err);
|
||||
|
Reference in New Issue
Block a user