Comparing version 10.0.0 to 11.0.0
@@ -218,2 +218,6 @@ 'use strict'; | ||
if (!err && res.statusCode >= 400) { | ||
err = Boom.create(res.statusCode, res.statusMessage); | ||
} | ||
if (err) { | ||
@@ -227,3 +231,3 @@ req.abort(); | ||
clearTimeout(timeoutId); | ||
this.emit('response', err, req, res, start, uri); | ||
this.emit('response', err, { req, res, start, uri }); | ||
@@ -304,3 +308,3 @@ if (callback) { | ||
case 302: | ||
return 'GET'; | ||
return method; | ||
@@ -307,0 +311,0 @@ case 303: |
{ | ||
"name": "wreck", | ||
"description": "HTTP Client Utilities", | ||
"version": "10.0.0", | ||
"version": "11.0.0", | ||
"repository": "git://github.com/hapijs/wreck", | ||
@@ -20,4 +20,4 @@ "main": "lib/index", | ||
"devDependencies": { | ||
"code": "3.x.x", | ||
"lab": "11.x.x", | ||
"code": "4.x.x", | ||
"lab": "13.x.x", | ||
"require-reload": "0.2.x" | ||
@@ -24,0 +24,0 @@ }, |
@@ -96,3 +96,3 @@ ![wreck Logo](https://raw.github.com/hapijs/wreck/master/images/wreck.png) | ||
- `redirects` - The maximum number of redirects to follow. | ||
- `redirect303` - if `true`, treats HTTP 303 status code the same way as a 301/302. Defaults to no redirection on 303. | ||
- `redirect303` - if `true`, a HTTP 303 status code will redirect using a GET method. Defaults to no redirection on 303. | ||
- `beforeRedirect` - A callback function that is called before a redirect is triggered, using the signature | ||
@@ -123,3 +123,3 @@ `function(redirectMethod, statusCode, location, resHeaders, redirectOptions, next)` where: | ||
- `callback` - The optional callback function using the signature `function (err, response)` where: | ||
- `err` - Any error that may have occurred during the handling of the request. | ||
- `err` - Any error that may have occurred during the handling of the request or a Boom error object if the response has an error status code. | ||
- `response` - The [HTTP Incoming Message](http://nodejs.org/api/http.html#http_http_incomingmessage) | ||
@@ -152,5 +152,5 @@ object, which is also a readable stream. | ||
- `callback` - The callback function using the signature `function (err, response, payload)` where: | ||
- `err` - Any error that may have occurred during handling of the request. | ||
- `err` - Any error that may have occurred during handling of the request or a Boom error object if the response has an error status code. | ||
- `response` - The [HTTP Incoming Message](http://nodejs.org/api/http.html#http_http_incomingmessage) | ||
object, which is also a readable stream. | ||
object, which is a readable stream that has "ended" and contains no more data to read. | ||
- `payload` - The payload in the form of a Buffer or (optionally) parsed JavaScript object (JSON). | ||
@@ -168,5 +168,5 @@ | ||
- `callback` - The callback function using the signature `function (err, response, payload)` where: | ||
- `err` - Any error that may have occurred during handling of the request. | ||
- `err` - Any error that may have occurred during handling of the request or a Boom error object if the response has an error status code. | ||
- `response` - The [HTTP Incoming Message](http://nodejs.org/api/http.html#http_http_incomingmessage) | ||
object, which is also a readable stream. | ||
object, which is a readable stream that has "ended" and contains no more data to read. | ||
- `payload` - The payload in the form of a Buffer or (optionally) parsed JavaScript object (JSON). | ||
@@ -183,5 +183,5 @@ | ||
- `callback` - The callback function using the signature `function (err, response, payload)` where: | ||
- `err` - Any error that may have occurred during handling of the request. | ||
- `err` - Any error that may have occurred during handling of the request or a Boom error object if the response has an error status code. | ||
- `response` - The [HTTP Incoming Message](http://nodejs.org/api/http.html#http_http_incomingmessage) | ||
object, which is also a readable stream. | ||
object, which is a readable stream that has "ended" and contains no more data to read. | ||
- `payload` - The payload in the form of a Buffer or (optionally) parsed JavaScript object (JSON). | ||
@@ -199,5 +199,5 @@ | ||
- `callback` - The callback function using the signature `function (err, response, payload)` where: | ||
- `err` - Any error that may have occurred during handling of the request. | ||
- `err` - Any error that may have occurred during handling of the request or a Boom error object if the response has an error status code. | ||
- `response` - The [HTTP Incoming Message](http://nodejs.org/api/http.html#http_http_incomingmessage) | ||
object, which is also a readable stream. | ||
object, which is a readable stream that has "ended" and contains no more data to read. | ||
- `payload` - The payload in the form of a Buffer or (optionally) parsed JavaScript object (JSON). | ||
@@ -215,5 +215,5 @@ | ||
- `callback` - The callback function using the signature `function (err, response, payload)` where: | ||
- `err` - Any error that may have occurred during handling of the request. | ||
- `err` - Any error that may have occurred during handling of the request or a Boom error object if the response has an error status code. | ||
- `response` - The [HTTP Incoming Message](http://nodejs.org/api/http.html#http_http_incomingmessage) | ||
object, which is also a readable stream. | ||
object, which is a readable stream that has "ended" and contains no more data to read. | ||
- `payload` - The payload in the form of a Buffer or (optionally) parsed JavaScript object (JSON). | ||
@@ -256,3 +256,3 @@ | ||
`https` agent with `rejectUnauthorized` set to true. All agents have | ||
`maxSockets` configured to `Infinity`. They are each instances of the node.js | ||
`maxSockets` configured to `Infinity`. They are each instances of the Node.js | ||
[Agent](http://nodejs.org/api/http.html#http_class_http_agent) and expose the | ||
@@ -270,3 +270,15 @@ standard properties. | ||
Below is another example that sets the certificate details for all HTTPS requests. | ||
```js | ||
const HTTPS = require('https'); | ||
const Wreck = require('wreck'); | ||
Wreck.agents.https = new HTTPS.Agent({ | ||
cert, | ||
key, | ||
ca | ||
}); | ||
``` | ||
### Events | ||
@@ -291,17 +303,17 @@ | ||
The response event is always emitted for any request that *wreck* makes. The | ||
handler should accept the following arguments `(error, request, response, start, | ||
uri)` where: | ||
handler should accept the following arguments `(err, details)` where: | ||
- `error` - a Boom error | ||
- `request` - the raw `ClientHttp` request object | ||
- `response` - the raw `IncomingMessage` response object | ||
- `start` - the time that the request was initiated | ||
- `uri` - the result of `Url.parse(uri)`. This will provide information about | ||
the resource requested. Also includes the headers and method. | ||
- `err` - a Boom error | ||
- `details` - object with the following properties | ||
- `req` - the raw `ClientHttp` request object | ||
- `res` - the raw `IncomingMessage` response object | ||
- `start` - the time that the request was initiated | ||
- `uri` - the result of `Url.parse(uri)`. This will provide information about | ||
the resource requested. Also includes the headers and method. | ||
This event is useful for logging all requests that go through *wreck*. The error | ||
and response arguments can be undefined depending on if an error occurs. Please | ||
This event is useful for logging all requests that go through *wreck*. The `err` | ||
and `res` arguments can be undefined depending on if an error occurs. Please | ||
be aware that if multiple modules are depending on the same cached *wreck* | ||
module that this event can fire for each request made across all modules. The | ||
start argument is the timestamp when the request was started. This can be | ||
`start` property is the timestamp when the request was started. This can be | ||
useful for determining how long it takes *wreck* to get a response back and | ||
@@ -317,3 +329,3 @@ processed. | ||
const symbol = Symbol.for('wreck'); | ||
process[symbol].on('response', (err) => { | ||
process[symbol].on('response', (err, details) => { | ||
@@ -320,0 +332,0 @@ if (err) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35863
444
326