diff --git a/index.js b/index.js index 62a485e..1c72129 100644 --- a/index.js +++ b/index.js @@ -138,10 +138,6 @@ function got(url, opts, cb) { var statusCode = response.statusCode; var res = response; - if (proxy) { - proxy.emit('response', res); - } - // auto-redirect only for GET and HEAD methods if (isRedirect(statusCode) && 'location' in res.headers && (opts.method === 'GET' || opts.method === 'HEAD')) { // discard response @@ -163,6 +159,10 @@ function got(url, opts, cb) { return; } + if (proxy) { + proxy.emit('response', res); + } + if (['gzip', 'deflate'].indexOf(res.headers['content-encoding']) !== -1) { res = res.pipe(zlib.createUnzip()); } diff --git a/readme.md b/readme.md index 0e13746..6894c73 100644 --- a/readme.md +++ b/readme.md @@ -128,7 +128,7 @@ When in stream mode, you can listen for events: ##### .on('response', response) -`response` event to get the response object. +`response` event to get the response object of the final request. ##### .on('redirect', response, nextOptions)