Releases: sindresorhus/got
3.3.1
3.3.0
3.2.0
json
option now sets Accept
header to application/json
(if it was not specified in headers
)
3.1.0
error
event now have additional body
and response
arguments in callback:
got('http://giggle.com')
.on('error', function (error, body, response) {
console.log(error, body, response);
});
3.0.0
Changes
52490b2 New redirect
event
This event fired before any redirect with response
and nextOptions
objects. You can access cookies and store them to be passed with next request in nextOptions
.
got('cookie.com')
.on('redirect', function (res, nextOptions) {
nextOptions.headers.cookie = cookie(res);
});
Breaking changes
2302a1e Redirects enabled only for GET and HEAD methods
As rfc2616 HTTP 1.1 says:
If the 302 status code is received in response to a request other
than GET or HEAD, the user agent MUST NOT automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.
Now got
will not auto-redirect you with unsafe methods (like POST or DELETE), which can cause lots of troubles.
2.9.0
Validation
Options
url
now acceptshttp.request
options as first argument 47da118query
option added 53df1ca
2.8.0
- Don't mutate the user-supplied options object ae73837
- infinity-agent updated to
2.0.0
- which uses backported Agent from Node core c06d741- Every request (in Node 0.10) will now have
Connection: close
header instead ofConnection: keep-alive
.maxSockets
is nowInfinity
always - if you want different value, passnull
or new Agent instance.
- Every request (in Node 0.10) will now have
2.7.2
Fixed absent nested error on parse error of response.
2.7.1
Parse response with non-2xx status code, when json
option is true
.
2.7.0
New json
option for auto-parsing JSON response. abdd0f0
Before:
got('jsonendpoint.com', function (err, data) {
if (err) { return cb(err); }
var json;
try {
json = JSON.parse(data);
} catch (e) {
return cb(new Error('Reponse from jsonendpoint.com is broken: ' + e.message));
}
// working with json
});
After:
got('jsonendpoint.com', {json: true}, function (err, json) {
if (err) { return cb(err); }
// working with json
});