got
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -68,2 +68,6 @@ 'use strict'; | ||
if (proxy) { | ||
proxy.emit('response', res); | ||
} | ||
// redirect | ||
@@ -104,3 +108,3 @@ if (status.redirect[statusCode] && 'location' in res.headers) { | ||
read(res, encoding, function (err, data) { | ||
cb.call(null, err, data, response); | ||
cb.call(null, err, data, response); | ||
}); | ||
@@ -107,0 +111,0 @@ }).once('error', cb); |
{ | ||
"name": "got", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Simplified HTTP/HTTPS requests", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -9,3 +9,3 @@ # got [![Build Status](https://travis-ci.org/sindresorhus/got.svg?branch=master)](https://travis-ci.org/sindresorhus/got) | ||
Use [request](https://github.com/mikeal/request) if you need more. | ||
Created because [`request`](https://github.com/mikeal/request) is bloated *(several megabytes!)* and slow. | ||
@@ -103,2 +103,10 @@ | ||
##### .on('response', response) | ||
When in stream mode, you can listen for the `response` event to get the response object. | ||
###### response | ||
The [response object](http://nodejs.org/api/http.html#http_http_incomingmessage). | ||
#### got.get(url, [options], [callback]) | ||
@@ -128,8 +136,23 @@ #### got.post(url, [options], [callback]) | ||
}) | ||
}, function (err, data, res) {}); | ||
}, function () {}); | ||
``` | ||
## Tip | ||
It's a good idea to set the `'user-agent'` header so the provider can more easily see how their resource is used. By default it's the URL to this repo. | ||
```js | ||
var got = require('got'); | ||
got('todomvc.com', { | ||
headers: { | ||
'user-agent': 'https://github.com/your-username/repo-name' | ||
} | ||
}, function () {}); | ||
``` | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8570
136
156
3