JavaScript How to decode gzip or utf-8 response in node? decode gzip response,decode gzip response php,decode gzip encoding,

I am using node request module to do some get request.I am getting the response body like

{
   body: '\u001f?\b\u0000\u0000\u0000\u0000\u0000...............' 
}

i have the header parameters and request like this,

var params = {
          url: options.url,
          headers: {
                'Accept-Encoding': "gzip, deflate",
                'Accept': '*/*',
                'Accept-Language': 'en-US,en;q=0.5',
                'Accept-Charset' : 'utf-8',
                'Content-Type' : 'application/json',
                 'User-Agent' : 'Mozilla/5.0'
             }
         };

 request(params, function (error, response, body) {   

        //response.setEncoding('utf8');
        //response.setEncoding('binary');

        console.log(response);        
 })

I tried

 //response.setEncoding('utf8');
 //response.setEncoding('binary');

and new Buffer(response.body, 'ascii').toString('utf8') to read the body content but its not working.

how to read the body content properly as JSON ?

Answer:1

I am working on a web page, that has to be 100% high. I did it so, it works fine everywhere, except on Android Firefox. The problem is: When I open the page for first time, in landscape mode - the ...

I am working on a web page, that has to be 100% high. I did it so, it works fine everywhere, except on Android Firefox. The problem is: When I open the page for first time, in landscape mode - the ...

  1. firefox android address bar bottom
  2. firefox android address bar hide
  3. firefox android address bar
  4. firefox android move address bar to bottom
  5. firefox android dark address bar
  6. firefox android remove address bar
  7. firefox android icon in address bar
  8. firefox android auto hide address bar
  9. firefox android always show address bar

I am trying to upload doc or docx files in my application : The view : <div class="col-xs-12"> <input type="file" ng-file-select="onFileSelect($files)"/> <table> &...

I am trying to upload doc or docx files in my application : The view : <div class="col-xs-12"> <input type="file" ng-file-select="onFileSelect($files)"/> <table> &...

I am trying to execute jQuery Ajax request with the following code: $.ajax({ url: '<MY_URL>', type: 'POST', contentType: 'application/json;charset=UTF-8', data: JSON.stringify(...

I am trying to execute jQuery Ajax request with the following code: $.ajax({ url: '<MY_URL>', type: 'POST', contentType: 'application/json;charset=UTF-8', data: JSON.stringify(...

  1. jquery ajax not working
  2. jquery not working ajax loaded content

I have a problem with my site, it's based on Joomla 2.5.16 I will try to explain my problem as good as possible. On my site i have a zipcode checker, were people can check the availability of fiber ...

I have a problem with my site, it's based on Joomla 2.5.16 I will try to explain my problem as good as possible. On my site i have a zipcode checker, were people can check the availability of fiber ...