Simple stream -> http post request
Heavily based on feross's simple-get. Instead of passing a body value and letting the library end the request for you, stream-post just returns the http request (req
). stream-post drops redirect support since that requires buffered data.
$ npm install --save stream-post
var streamPost = require('stream-post')
var fs = require('fs')
fs.createReadStream('beep.txt')
.pipe(streamPost({url: '/'}, function (err, res) {
if (err) throw err
res.pipe(process.stdout)
}))
Returns an http.ClientRequest
.
Required
Type: object
A set of options to pass to http.request
. The following special options are also provided:
Type: boolean
Default: false
When set, the library will add JSON headers (accept
and content-type
) and attempt to decode a JSON response body.
Required
Type: function
Arguments: err, res, [data]
A callback to be called with a request error and the http.IncomingMessage
response. The response data
is not read by default. Calling streamPost.concat
reads the data as a Buffer or JSON (with options.json
).
MIT © Ben Drucker