typed-rest-client
Advanced tools
Comparing version 1.0.11 to 1.1.2
@@ -95,2 +95,3 @@ /// <reference types="node" /> | ||
private _prepareRequest(method, requestUrl, headers); | ||
private _mergeHeaders(headers); | ||
private _getAgent(requestUrl); | ||
@@ -97,0 +98,0 @@ private _getProxy(requestUrl); |
@@ -280,4 +280,4 @@ "use strict"; | ||
info.options.method = method; | ||
info.options.headers = headers || {}; | ||
info.options.headers["User-Agent"] = this.userAgent; | ||
info.options.headers = this._mergeHeaders(headers); | ||
info.options.headers["user-agent"] = this.userAgent; | ||
info.options.agent = this._getAgent(requestUrl); | ||
@@ -292,2 +292,9 @@ // gives handlers an opportunity to participate | ||
} | ||
_mergeHeaders(headers) { | ||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {}); | ||
if (this.requestOptions && this.requestOptions.headers) { | ||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); | ||
} | ||
return lowercaseKeys(headers || {}); | ||
} | ||
_getAgent(requestUrl) { | ||
@@ -294,0 +301,0 @@ let agent; |
{ | ||
"name": "typed-rest-client", | ||
"version": "1.0.11", | ||
"version": "1.1.2", | ||
"description": "Node Rest and Http Clients for use with TypeScript", | ||
@@ -36,2 +36,3 @@ "main": "./RestClient.js", | ||
"mocha": "^3.5.3", | ||
"nock": "9.6.1", | ||
"react-scripts": "1.1.5", | ||
@@ -43,3 +44,2 @@ "shelljs": "0.7.6", | ||
"dependencies": { | ||
"nock": "9.6.1", | ||
"tunnel": "0.0.4", | ||
@@ -46,0 +46,0 @@ "underscore": "1.8.3" |
@@ -164,5 +164,6 @@ "use strict"; | ||
let obj; | ||
let contents; | ||
// get the result from the body | ||
try { | ||
let contents = yield res.readBody(); | ||
contents = yield res.readBody(); | ||
if (contents && contents.length > 0) { | ||
@@ -193,2 +194,6 @@ if (options && options.deserializeDates) { | ||
} | ||
else if (contents && contents.length > 0) { | ||
// it may be the case that the exception is in the body message as string | ||
msg = contents; | ||
} | ||
else { | ||
@@ -195,0 +200,0 @@ msg = "Failed request: (" + statusCode + ")"; |
@@ -14,2 +14,3 @@ "use strict"; | ||
function getUrl(resource, baseUrl) { | ||
const pathApi = path.posix || path; | ||
if (!baseUrl) { | ||
@@ -28,3 +29,3 @@ return resource; | ||
resultantUrl.host = resultantUrl.host || base.host; | ||
resultantUrl.pathname = path.posix.resolve(base.pathname, resultantUrl.pathname); | ||
resultantUrl.pathname = pathApi.resolve(base.pathname, resultantUrl.pathname); | ||
if (!resultantUrl.pathname.endsWith('/') && resource.endsWith('/')) { | ||
@@ -31,0 +32,0 @@ resultantUrl.pathname += '/'; |
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
144564
2
1477
9
- Removednock@9.6.1
- Removedassertion-error@1.1.0(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedchai@4.5.0(transitive)
- Removedcheck-error@1.0.3(transitive)
- Removeddebug@3.2.7(transitive)
- Removeddeep-eql@4.1.4(transitive)
- Removeddeep-equal@1.1.2(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-func-name@2.0.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedis-arguments@1.1.1(transitive)
- Removedis-date-object@1.0.5(transitive)
- Removedis-regex@1.1.4(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedlodash@4.17.21(transitive)
- Removedloupe@2.3.7(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.1.3(transitive)
- Removednock@9.6.1(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-is@1.1.6(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedpathval@1.1.1(transitive)
- Removedpropagate@1.0.0(transitive)
- Removedqs@6.13.0(transitive)
- Removedregexp.prototype.flags@1.5.3(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedtype-detect@4.1.0(transitive)