stream-post

1.0.0 • Public • Published

stream-post Build Status

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.

Install

$ npm install --save stream-post

Usage

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)  
  }))

API

streamPost(options, callback) -> stream

Returns an http.ClientRequest.

options

Required
Type: object

A set of options to pass to http.request. The following special options are also provided:

json

Type: boolean
Default: false

When set, the library will add JSON headers (accept and content-type) and attempt to decode a JSON response body.

callback

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).

License

MIT © Ben Drucker

Readme

Keywords

Package Sidebar

Install

npm i stream-post

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • bendrucker