Comparing version 1.0.7 to 1.0.8
@@ -282,6 +282,9 @@ "use strict"; | ||
if (RE_CONTENT_TYPE_JSON.test(requestContentType)) { | ||
state.data = (0, _stringify.default)(data); | ||
} else if (data && data.toString && typeof data.toString === 'function') { | ||
state.data = data.toString(); | ||
if (typeof state.data !== 'string' && !Buffer.isBuffer(state.data)) { | ||
if (RE_CONTENT_TYPE_JSON.test(requestContentType)) { | ||
state.data = (0, _stringify.default)(data); | ||
} else if (data && data.toString && typeof data.toString === 'function') { | ||
state.data = data.toString(); | ||
} // TODO: handle when state.data might not be a string or Buffer | ||
} // apply content length header | ||
@@ -292,2 +295,6 @@ | ||
options.headers[HTTP_HEADERS.CONTENT_LENGTH] = options.headers[HTTP_HEADERS.CONTENT_LENGTH] || Buffer.byteLength(state.data); | ||
} | ||
if (Buffer.isBuffer(state.data)) { | ||
options.headers[HTTP_HEADERS.CONTENT_LENGTH] = options.headers[HTTP_HEADERS.CONTENT_LENGTH] || state.data.length; | ||
} // setup failover if applicable | ||
@@ -294,0 +301,0 @@ |
@@ -0,1 +1,6 @@ | ||
# v1.0.8 - 03/19/2019 | ||
* Removed `prepublish` NPM script in favor of `prepare` | ||
* Added better handling around HTTP request body serialization | ||
# v1.0.7 - 03/12/2019 | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "reqlib", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "A library to simplify REST API requests and to provide utilities for handling common REST API consumer scenarios ", | ||
@@ -9,3 +9,3 @@ "main": "dist", | ||
"posttest": "nyc report --reporter=text-lcov | coveralls", | ||
"prepublish": "gulp build", | ||
"prepare": "gulp build", | ||
"pretest": "gulp clean && gulp lint", | ||
@@ -12,0 +12,0 @@ "test": "NODE_ENV=test nyc mocha ./test/src", |
Sorry, the diff of this file is not supported yet
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
84215
807