1.0.2 • Published 10 years ago
simple-get-stream v1.0.2
simple-get-stream

Simply wraps simple-get and his methods to return Response stream instead of Request stream. Simple as
simpleGet.get(url).pipe(process.stdout)
Install
npm i simple-get-stream --saveUsage
For more use-cases see the tests
const simpleGetStream = require('simple-get-stream')simpleGetStream
Request a page and return a response stream
Params
<opts>{String|Object}: Url or options object, passed tosimple-get.returns{Stream}: Response stream instead of Request stream assimple-getdoes.
Example
const request = require('simple-get-stream')
const stream = request('http://www.tunnckocore.tk')
stream.once('error', console.error)
stream.pipe(process.stdout) // => html content of the pageAdvanced example
Showing use of
.postmethod and getting the response, using through2
const through2 = require('through2')
const request = require('simple-get-stream')
const stream = request.post({
url: 'http://httpbin.org/post',
body: JSON.stringify({
foo: 'bar',
baz: 'qux'
})
})
stream.once('error', console.error)
stream.pipe(through2(function (buf) {
var res = buf.toString()
var data = JSON.parse(res)
console.log(data.json)
/* => {
foo: 'bar',
baz: 'qux'
} */
}))Related
- github-base: Base methods for creating node.js apps that work with the GitHub… more | homepage
- npm-info: Base class for downloading data from the npm registry | homepage
- request-all: Performs a multiple requests and data from all pages are concatenated… more | homepage
- simple-get: Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate,… more | homepage
- simple-get-stream: Simply wraps
simple-getand his methods to return Response stream instead… more | homepage - then-got: Promisified
simple-get. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.