Skip to content
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

Can't intercept html in response body #9

Closed
topheman opened this issue Dec 10, 2014 · 3 comments
Closed

Can't intercept html in response body #9

topheman opened this issue Dec 10, 2014 · 3 comments

Comments

@topheman
Copy link

Hello Villadora,

I can't seem to intercept html in a response body - here is the test case : topheman@264e451

Other use case where intercept doesn't work : https://api.github.com/
Even if it's json returning and I can access data in the intercept callback, but there is an encoding problem (though everything is in utf8).

Tophe

@villadora villadora added the bug label Dec 18, 2014
@villadora
Copy link
Owner

Hi Tophe,
As the first problem, I tried it, you should try res.text in test case. It works, I comments on your commit.

For api.github.com, it's very wired, I thought there might be a https relative problem, but I tried https://httpbin.org, everything works fine. I doubt it's somehow relative to how the code to decode the buffer. I'll keep it in the issues list to when I can finally take time to figure it out.

PS: in the final response, resp.body contains the correct json object =.=

@joshq00
Copy link

joshq00 commented Dec 26, 2014

I also ran into this. It turned out gzip was the culprit for me.
I added this:

decorateRequest: function ( req ) {
    req.headers[ 'Accept-Encoding' ] = 'utf8';
    return req;
}

and data.toString( 'utf8' ) stopped giving me jumbled poo-poo

@mlenkeit
Copy link

mlenkeit commented Jan 9, 2015

Not sure if this is related: I faced a similar issue where I couldn't access any data from the response in the intercept hook (also when proxying to Github), yet I saw the response in the browser. It turned out to be a caching-related issue.
I added this to solve the problem.

decorateRequest: function(req) {
  delete req.headers['if-modified-since'];
  delete req.headers['if-none-match'];
  return req;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants