Skip to content

Latest commit

 

History

History
58 lines (35 loc) · 1.7 KB

readme.md

File metadata and controls

58 lines (35 loc) · 1.7 KB

stream-post Build Status Greenkeeper badge

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