You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

http-observable

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-observable

Node.js http module binding using the Reactive Extensions for JavaScript (RxJS) Observable to handle stream http response

0.1.0
latest
Source
npm
Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Source

http-observable

A simple RxJs Observable binding for Node.js http module. This observable is useful to handle streaming http response.

This module is a work in progress. TODO list:

  • status() - To find out the status of the http/https calls
  • headers() - To get the observable result on response headers
  • body() - Body parse and read response Body
  • Methods get and post and generic request
  • SSL validations
  • Socket and connect timeout implementations

Install

npm i http-observable

Usage


    var HttpObservable = require('http-observable');

    // Http Request options
    // https://nodejs.org/api/http.html#http_http_request_options_callback
    //
    var options = {
        hostname: 'somestreamingapi.com',
        port: 80,
        path: '/stream'
    };

    var response = HttpObservable(options).request();
    
        response.body().subscribe(
              function onNext(chunk) {
                  //Write the data chunk to response stream (Or process the data)
                  res.write(chunk);
              },
              function onError() {
                  //Handle errors here.
                  res.write('error');
              },
              function onCompleted() {
                  //End of streaming data. Write the end response (Or equivalent tasks)
                  res.end('</body></html>');
              }
        );

Options

https://nodejs.org/api/http.html#http_http_request_options_callback

Example

https://github.com/subii/express-streaming-app

Keywords

http

FAQs

Package last updated on 29 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts