Skip to content

Releases: sindresorhus/got

3.3.0

30 Jun 15:51
Compare
Choose a tag to compare
  • 87d98e1 Added content-length header in requests with body.
  • d7a66ba Fallback on pathname option, if no path is present.

v3.2.0...v3.3.0

3.2.0

09 May 07:46
Compare
Choose a tag to compare

json option now sets Accept header to application/json (if it was not specified in headers)

v3.1.0...v3.2.0

3.1.0

09 May 07:44
Compare
Choose a tag to compare

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);
    });

v3.0.0...v3.1.0

3.0.0

06 May 06:38
Compare
Choose a tag to compare

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.

v2.9.0...v3.0.0

2.9.0

26 Apr 16:10
Compare
Choose a tag to compare

angry-bear

Validation

  • url now throws error if not string or object 6b01569
  • Nice error on wrong body option type a0913bc

Options

v2.8.0...v2.9.0

2.8.0

21 Apr 05:45
Compare
Choose a tag to compare
  • 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 of Connection: keep-alive. maxSockets is now Infinity always - if you want different value, pass null or new Agent instance.

v2.7.2...v2.8.0

2.7.2

08 Apr 19:05
Compare
Choose a tag to compare

Fixed absent nested error on parse error of response.

v2.7.1...v2.7.2

2.7.1

08 Apr 11:05
Compare
Choose a tag to compare

Parse response with non-2xx status code, when json option is true.

v2.7.0...v2.7.1

2.7.0

06 Apr 11:34
Compare
Choose a tag to compare

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
});

v2.6.0...v2.7.0

2.6.0

03 Apr 14:59
Compare
Choose a tag to compare

Thanks to nested-error-stacks by @mdlavin got now emits much more detailed errors! For example Error: getaddrinfo ENOTFOUND now looks like:

GotError: Request to .com failed
    at ClientRequest.<anonymous> (index.js:123:7)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.emit (events.js:95:17)
    at Socket.socketErrorListener (http.js:1552:9)
    at Socket.emit (events.js:95:17)
    at net.js:834:16
    at process._tickCallback (node.js:442:13)
Caused By: Error: getaddrinfo ENOTFOUND
    at errnoException (dns.js:37:11)
    at Object.onanswer [as oncomplete] (dns.js:124:16)

Same goes for ungzip errors and response stream reading errors. All of them will be wrapped in GotError with url in message.

Highlights

  • read-all-stream was updated to ^2.0.0 - release fixes hanging requests on error in underlying streams (like ungzip) 3e55aa6

Changes

v2.5.0...v2.6.0