then-request
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -63,2 +63,14 @@ 'use strict'; | ||
}()); | ||
var StreamBody = (function () { | ||
function StreamBody(body) { | ||
this._body = body; | ||
} | ||
StreamBody.prototype.getHeaders = function () { | ||
return Promise.resolve({}); | ||
}; | ||
StreamBody.prototype.pipe = function (stream) { | ||
this._body.pipe(stream); | ||
}; | ||
return StreamBody; | ||
}()); | ||
function handleBody(options) { | ||
@@ -81,2 +93,5 @@ if (options.form) { | ||
if (!Buffer.isBuffer(body)) { | ||
if (typeof body.pipe === 'function') { | ||
return new StreamBody(body); | ||
} | ||
throw new TypeError('body should be a Buffer or a String'); | ||
@@ -83,0 +98,0 @@ } |
@@ -30,4 +30,4 @@ /// <reference types="node" /> | ||
form?: FormData; | ||
body?: string | Buffer; | ||
body?: string | Buffer | NodeJS.ReadableStream; | ||
} | ||
export { Options }; |
{ | ||
"name": "then-request", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "A request library that returns promises, inspired by request", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -75,3 +75,3 @@ # then-request | ||
- `headers` - http headers (default: `{}`) | ||
- `body` - body for PATCH, POST and PUT requests. Must be a `Buffer` or `String` (only strings are accepted client side) | ||
- `body` - body for PATCH, POST and PUT requests. Must be a `Buffer`, `ReadableStream` or `String` (only strings are accepted client side) | ||
- `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json`. Does not have any affect on how the response is treated. | ||
@@ -78,0 +78,0 @@ - `form` - You can pass a `FormData` instance to the `form` option, this will manage all the appropriate headers for you. Does not have any affect on how the response is treated. |
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
29209
422