Skip to content

Commit

Permalink
fix(HttpClient): turn res stream to readable in HttpClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Marton committed Jun 6, 2018
1 parent 1edd6da commit cf06d1d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/HttpClient.js
Expand Up @@ -188,6 +188,8 @@ function rawRequest(opts, cb) {

var requestTime = new Date().getTime();
req = proto.request(opts, function onResponse(res) {
res.resume();

var latency = Date.now() - requestTime;
res.headers['x-request-received'] = requestTime;
res.headers['x-request-processing-time'] = latency;
Expand Down
16 changes: 16 additions & 0 deletions test/StringClient.test.js
Expand Up @@ -39,6 +39,22 @@ describe('StringClient', function () {
SERVER.close(done);
});

it('should make a request',
function (done) {
SERVER.get('/ping', function (req, res, next) {
res.send('pong');
return next();
});

CLIENT.get({
path: '/ping'
}, function (err, req, res, data) {
assert.ifError(err);
assert.equal(data, 'pong');
return done();
});
});

it('should support decoding gzipped utf8 multibyte responses',
function (done) {
var payload = fs.readFileSync(path.join(
Expand Down

0 comments on commit cf06d1d

Please sign in to comment.