-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option "intercept" throw error when use a truncated gzip request. #177
Comments
@JanzenZhangChen Thank you for this report and suggestion. Do you have a test case that's failing that I can use to verify your fix? Thanks! |
sorry, i cant provide our cgi to you,but I found one in cn.bing.com(china) http://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&nc=1490973090201&pid=hp&video=1 if you use fiddler to catch this request, in Raw section of response body, it said: |
The fix suggested by @JanzenZhangChen fixed some issues I was getting too. Do you need a PR? |
I found an separate bug in the parser for zip that I think may have been causing this. The patch is in the 1.0.* line. If you're still experiencing the issue, I'd be very happy to get a PR if you would like to accelerate resolution. |
I created a PR to the project. I couldnt pass the "on the nose" mocha test. And I have no idea how to fix this problem. |
Note we have the issue when receiving a 204 (No-content) response on a if (srcReq.method === 'DELETE') {
delete proxyReq.headers['accept-encoding'];
} |
Hi guys, any update on this ? I am experiencing the same issue.
|
When using "intercept" option, the http request is using gzip,but the data is truncated.So the proxy will throw an error of
"Error: unexpected end of file
at Zlib._handle.onerror (zlib.js:370:17)
at Gunzip.Zlib._processChunk (zlib.js:538:30)
at zlibBufferSync (zlib.js:239:17)"
we can use a official method to solve this problem.
https://nodejs.org/api/zlib.html#zlib_compressing_http_requests_and_responses
(search truncated)
so I add some code in your lib.
function zipOrUnzip(method) {
return function(rspData, res) {
return (isResGzipped(res)) ? zlib[method](rspData, {
finishFlush: zlib.Z_SYNC_FLUSH //here
}) : rspData;
};
}
then the intercept option would be like:
intercept: function(rsp, data, req, res, callback) {
var resdata = data.toString(); //data would be Buffer
callback(null, resdata);
},
The text was updated successfully, but these errors were encountered: