Browse Source

Access to body of non-200 responses in stream mode

http2
Kirill Solovev 10 years ago
committed by Kirill Solovev
parent
commit
e56f91373a
  1. 4
      index.js
  2. 4
      test/test-http.js

4
index.js

@ -65,8 +65,8 @@ function got(url, opts, cb) {
if (!cb) {
proxy = duplexify();
// forward errors on the stream
cb = function (err) {
proxy.emit('error', err);
cb = function (err, data, response) {
proxy.emit('error', err, data, response);
};
}

4
test/test-http.js

@ -89,8 +89,10 @@ tape('emit response object to stream', function (t) {
tape('proxy errors to the stream', function (t) {
got(s.url + '/404')
.on('error', function (err) {
.on('error', function (err, data, res) {
t.equal(err.code, 404);
t.equal(data, 'not');
t.ok(res);
t.end();
});
});

Loading…
Cancel
Save