Skip to content

Instantly share code, notes, and snippets.

@djaiss
Created June 6, 2018 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djaiss/d223ec9d85d9f0814004ee5a19ed9a2a to your computer and use it in GitHub Desktop.
Save djaiss/d223ec9d85d9f0814004ee5a19ed9a2a to your computer and use it in GitHub Desktop.
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