postman-request
Advanced tools
Comparing version 2.88.1-postman.29 to 2.88.1-postman.30
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "2.88.1-postman.29", | ||
"version": "2.88.1-postman.30", | ||
"repository": { | ||
@@ -13,0 +13,0 @@ "type": "git", |
@@ -130,2 +130,45 @@ 'use strict' | ||
/** | ||
* Return request headers in [{key: headerName, value: headerValue}] form | ||
* @param {String} [headerString] - headers string created by Node stored in ClientRequest._header | ||
* | ||
* */ | ||
function parseRequestHeaders (headerString) { | ||
var arr = headerString.split('\r\n') | ||
var acc = [] | ||
// first element of accumulator is not a header | ||
// last two elements are empty strings | ||
for (var i = 1; i < arr.length - 2; i++) { | ||
// header name cannot have a ':' but header value allows it | ||
// therefore we split on the index of the first ':' | ||
var splitIndex = arr[i].indexOf(':') | ||
acc.push({ | ||
key: arr[i].slice(0, splitIndex), | ||
value: arr[i].slice(splitIndex + 2) | ||
}) | ||
} | ||
return acc | ||
} | ||
/** | ||
* Return response headers in [{key: headerName, value: headerValue}] form | ||
* @param {Array} [rawHeaders] - https://nodejs.org/api/http.html#http_message_rawheaders | ||
* | ||
* */ | ||
function parseResponseHeaders (rawHeaders) { | ||
var acc = [] | ||
for (var i = 0; i < rawHeaders.length; i = i + 2) { | ||
acc.push({ | ||
key: rawHeaders[i], | ||
value: rawHeaders[i + 1] | ||
}) | ||
} | ||
return acc | ||
} | ||
function Request (options) { | ||
@@ -898,3 +941,3 @@ // if given the method property in options, set property explicitMethod to true | ||
href: self.uri.href, | ||
headers: this.headers, | ||
headers: [], | ||
proxy: (self.proxy && { href: self.proxy.href }) || undefined, | ||
@@ -1232,3 +1275,3 @@ httpVersion: '1.1' | ||
statusCode: response.statusCode, | ||
headers: response.headers, | ||
headers: parseResponseHeaders(response.rawHeaders), | ||
httpVersion: response.httpVersion | ||
@@ -1905,2 +1948,4 @@ } | ||
self.req.end() | ||
self.req._header && (self._reqResInfo.request.headers = parseRequestHeaders(self.req._header)) | ||
} | ||
@@ -1907,0 +1952,0 @@ } |
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
243961
3285