Created
June 6, 2018 19:23
-
-
Save djaiss/d223ec9d85d9f0814004ee5a19ed9a2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request') | |
request( | |
{ | |
method: 'GET', | |
uri: 'http://localhost:1080/email' | |
} | |
, function (error, response, body) { | |
// body is the decompressed response body | |
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) | |
console.log('the decoded data is: ' + body) | |
} | |
) | |
.on('data', function (data) { | |
// decompressed data as it is received | |
console.log('decoded chunk: ' + data) | |
}) | |
.on('response', function (response) { | |
// unmodified http.IncomingMessage object | |
response.on('data', function (data) { | |
// compressed data as it is received | |
console.log('received ' + data.length + ' bytes of compressed data') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment