1

I have encountered a weird problem I don't know how to fix. I use the following code to print the body of the response.

proxy_response.setEncoding('utf-8');
proxy_response.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
});
proxy_response.on('end', function() {
    console.log('No more data in response.')
});

This code works fine with this website, but if I try it with Agar.io, it fails and prints a weird sequence of characters, even thogh the encoding is correct (According to the meta charset attribute of the response). I can view the correct source with chrome by typing view-source:agar.io into the search bar (This is what I would want my program to print). This is how the response looks like. This is the code I am confused about.

Distjubo
  • 959
  • 6
  • 21
  • First, it sounds like you are up to no-good. Second, you need to include all of your code for the creation of your proxy_response object so we can have a working example. – Preston S Sep 25 '15 at 16:27
  • thanks @PrestonS for trying to help. I edited the question, I hope you can help :) the code: http://pastebin.com/vt8DCHu9 – Distjubo Sep 25 '15 at 17:09
  • the weird thing is that it works for every other website I have tested, just not agario. – Distjubo Sep 25 '15 at 17:10

1 Answers1

1

Agar.io's response is gzipped.

In the response headers you see:

Content-Encoding: gzip

See this answer for how to unzip it. Basically, pipe it to gunzip

Community
  • 1
  • 1
Preston S
  • 2,751
  • 24
  • 37