postman-request
Advanced tools
Comparing version 2.88.1-postman.7.1 to 2.88.1-postman.8
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "2.88.1-postman.7.1", | ||
"version": "2.88.1-postman.8", | ||
"repository": { | ||
@@ -13,0 +13,0 @@ "type": "git", |
@@ -19,3 +19,4 @@ | ||
- Fixed `Request~getNewAgent` to account for `passphrase` while generating poolKey | ||
- Added support for extending the root CA certificates. | ||
- Added support for extending the root CA certificates | ||
- Added `verbose` mode to bubble up low-level request-response information | ||
@@ -707,2 +708,90 @@ ## Super simple to use | ||
### Using `options.verbose` | ||
Using this option the debug object holds low level request response information like remote address, negotiated ciphers etc. Example debug object: | ||
```js | ||
request({url: 'https://www.google.com', verbose: true}, function (error, response, body, debug) { | ||
// debug: | ||
/* | ||
[ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"href": "https://www.google.com/", | ||
"httpVersion": "1.1" | ||
}, | ||
"session": { | ||
"id": "9a1ac0d7-b757-48ad-861c-d59d6af5f43f", | ||
"reused": false, | ||
"data": { | ||
"addresses": { | ||
"local": { | ||
"address": "8.8.4.4", | ||
"family": "IPv4", | ||
"port": 61632 | ||
}, | ||
"remote": { | ||
"address": "172.217.31.196", | ||
"family": "IPv4", | ||
"port": 443 | ||
} | ||
}, | ||
"tls": { | ||
"reused": false, | ||
"authorized": true, | ||
"authorizationError": null, | ||
"cipher": { | ||
"name": "ECDHE-ECDSA-AES128-GCM-SHA256", | ||
"version": "TLSv1/SSLv3" | ||
}, | ||
"protocol": "TLSv1.2", | ||
"ephemeralKeyInfo": { | ||
"type": "ECDH", | ||
"name": "X25519", | ||
"size": 253 | ||
}, | ||
"peerCertificate": { | ||
"subject": { | ||
"country": "US", | ||
"stateOrProvince": "California", | ||
"locality": "Mountain View", | ||
"organization": "Google LLC", | ||
"commonName": "www.google.com", | ||
"alternativeNames": "DNS:www.google.com" | ||
}, | ||
"issuer": { | ||
"country": "US", | ||
"organization": "Google Trust Services", | ||
"commonName": "Google Internet Authority G3" | ||
}, | ||
"validFrom": "2019-03-01T09:46:35.000Z", | ||
"validTo": "2019-05-24T09:25:00.000Z", | ||
"fingerprint": "DF:6B:95:81:C6:03:EB:ED:48:EB:6C:CF:EE:FE:E6:1F:AD:01:78:34", | ||
"serialNumber": "3A15F4C87FB4D33993D3EEB3BF4AE5E4" | ||
} | ||
} | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"httpVersion": "1.1" | ||
}, | ||
"timingStart": 1552908287924, | ||
"timingStartTimer": 805.690674, | ||
"timings": { | ||
"socket": 28.356426000000056, | ||
"lookup": 210.3752320000001, | ||
"connect": 224.57993499999998, | ||
"secureConnect": 292.80315800000017, | ||
"response": 380.61268100000007, | ||
"end": 401.8332560000001 | ||
} | ||
} | ||
] | ||
*/ | ||
}); | ||
``` | ||
### Extending root CAs | ||
@@ -709,0 +798,0 @@ |
129
request.js
@@ -12,2 +12,3 @@ 'use strict' | ||
var aws4 = require('aws4') | ||
var uuid = require('uuid/v4') | ||
var httpSignature = require('http-signature') | ||
@@ -160,2 +161,3 @@ var mime = require('mime-types') | ||
self.writable = true | ||
self._debug = [] | ||
if (options.method) { | ||
@@ -196,2 +198,7 @@ self.explicitMethod = true | ||
// for this request (or redirect) store its debug logs in `_reqResInfo` and | ||
// store its reference in `_debug` which holds debug logs of every request | ||
self._reqResInfo = {} | ||
self._debug.push(self._reqResInfo) | ||
// additional postman feature starts | ||
@@ -246,3 +253,3 @@ // bind default events sent via options | ||
self._callback = self.callback | ||
self.callback = function () { | ||
self.callback = function (error, response, body) { | ||
if (self._callbackCalled) { | ||
@@ -252,3 +259,3 @@ return // Print a warning maybe? | ||
self._callbackCalled = true | ||
self._callback.apply(self, arguments) | ||
self._callback(error, response, body, self._debug) | ||
} | ||
@@ -470,3 +477,4 @@ self.on('error', self.callback.bind()) | ||
if (options.time) { | ||
// enable timings if verbose is true | ||
if (options.time || options.verbose) { | ||
self.timing = true | ||
@@ -478,2 +486,6 @@ | ||
if (options.verbose) { | ||
self.verbose = true | ||
} | ||
function setContentLength () { | ||
@@ -833,2 +845,9 @@ if (isTypedArray(self.body)) { | ||
self._reqResInfo.request = { | ||
method: self.method, | ||
href: self.uri.href, | ||
proxy: (self.proxy && { href: self.proxy.href }) || undefined, | ||
httpVersion: '1.1' | ||
} | ||
// We have a method named auth, which is completely different from the http.request | ||
@@ -885,2 +904,22 @@ // auth option. If we don't remove it, we're gonna have a bad time. | ||
self.req.on('socket', function (socket) { | ||
if (self.verbose) { | ||
// The reused socket holds all the session data which was injected in | ||
// during the first connection. This is done because events like | ||
// `lookup`, `connect` & `secureConnect` will not be triggered for a | ||
// reused socket and debug information will be lost for that request. | ||
var reusedSocket = Boolean(socket.__SESSION_ID && socket.__SESSION_DATA) | ||
if (!reusedSocket) { | ||
socket.__SESSION_ID = uuid() | ||
socket.__SESSION_DATA = {} | ||
} | ||
// @note make sure you don't serialize this object to avoid memory leak | ||
self._reqResInfo.session = { | ||
id: socket.__SESSION_ID, | ||
reused: reusedSocket, | ||
data: socket.__SESSION_DATA | ||
} | ||
} | ||
// `._connecting` was the old property which was made public in node v6.1.0 | ||
@@ -898,2 +937,18 @@ var isConnecting = socket._connecting || socket.connecting | ||
self.timings.connect = now() - self.startTimeNow | ||
if (self.verbose) { | ||
socket.__SESSION_DATA.addresses = { | ||
// local address | ||
// @note there's no `socket.localFamily` but `.address` method | ||
// returns same output as of remote. | ||
local: (typeof socket.address === 'function') && socket.address(), | ||
// remote address | ||
remote: { | ||
address: socket.remoteAddress, | ||
family: socket.remoteFamily, | ||
port: socket.remotePort | ||
} | ||
} | ||
} | ||
} | ||
@@ -903,2 +958,56 @@ | ||
self.timings.secureConnect = now() - self.startTimeNow | ||
if (self.verbose) { | ||
socket.__SESSION_DATA.tls = { | ||
// true if the session was reused | ||
reused: (typeof socket.isSessionReused === 'function') && socket.isSessionReused(), | ||
// true if the peer certificate was signed by one of the CAs specified | ||
authorized: socket.authorized, | ||
// reason why the peer's certificate was not been verified | ||
authorizationError: socket.authorizationError, | ||
// negotiated cipher name | ||
cipher: (typeof socket.getCipher === 'function') && socket.getCipher(), | ||
// negotiated SSL/TLS protocol version | ||
// @note Node >= v5.7.0 | ||
protocol: (typeof socket.getProtocol === 'function') && socket.getProtocol(), | ||
// type, name, and size of parameter of an ephemeral key exchange | ||
// @note Node >= v5.0.0 | ||
ephemeralKeyInfo: (typeof socket.getEphemeralKeyInfo === 'function') && socket.getEphemeralKeyInfo() | ||
} | ||
// peer certificate information | ||
// @note if session is reused, all certificate information is | ||
// stripped from the socket (returns {}). | ||
// Refer: https://github.com/nodejs/node/issues/3940 | ||
var peerCert = (typeof socket.getPeerCertificate === 'function') && (socket.getPeerCertificate() || {}) | ||
socket.__SESSION_DATA.tls.peerCertificate = { | ||
subject: peerCert.subject && { | ||
country: peerCert.subject.C, | ||
stateOrProvince: peerCert.subject.ST, | ||
locality: peerCert.subject.L, | ||
organization: peerCert.subject.O, | ||
organizationalUnit: peerCert.subject.OU, | ||
commonName: peerCert.subject.CN, | ||
alternativeNames: peerCert.subjectaltname | ||
}, | ||
issuer: peerCert.issuer && { | ||
country: peerCert.issuer.C, | ||
stateOrProvince: peerCert.issuer.ST, | ||
locality: peerCert.issuer.L, | ||
organization: peerCert.issuer.O, | ||
organizationalUnit: peerCert.issuer.OU, | ||
commonName: peerCert.issuer.CN | ||
}, | ||
validFrom: peerCert.valid_from && new Date(peerCert.valid_from), | ||
validTo: peerCert.valid_to && new Date(peerCert.valid_to), | ||
fingerprint: peerCert.fingerprint, | ||
serialNumber: peerCert.serialNumber | ||
} | ||
} | ||
} | ||
@@ -1003,3 +1112,3 @@ | ||
response.timingStart = self.startTime | ||
response.timingStartHRTime = self.startTimeNow | ||
response.timingStartTimer = self.startTimeNow | ||
@@ -1051,2 +1160,3 @@ // fill in the blanks for any periods that didn't trigger, such as | ||
} | ||
debug('response end', self.uri.href, response.statusCode, response.headers) | ||
@@ -1061,2 +1171,13 @@ }) | ||
self._reqResInfo.response = { | ||
statusCode: response.statusCode, | ||
httpVersion: response.httpVersion | ||
} | ||
if (self.timing) { | ||
self._reqResInfo.timingStart = self.startTime | ||
self._reqResInfo.timingStartTimer = self.startTimeNow | ||
self._reqResInfo.timings = self.timings | ||
} | ||
self.response = response | ||
@@ -1063,0 +1184,0 @@ response.request = self |
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
230911
3008
1251