http-observable
Advanced tools
Comparing version 0.0.3 to 0.1.0
@@ -18,2 +18,4 @@ var Http = require('http'); | ||
var req = Client.request(options, function(res) { | ||
//Send the status and message first. | ||
observer.onNext({statusCode: res.statusCode, statusMessage: res.statusMessage}); | ||
@@ -39,2 +41,38 @@ res.on('data', function(chunk) { | ||
module.exports = HttpObservable; | ||
function Response(source) { | ||
this.source = source; | ||
} | ||
Response.prototype.status = function () { | ||
return this.source.first(); | ||
}; | ||
// Response.prototype.headers = function () { | ||
// //return this.source.first(); | ||
// }; | ||
Response.prototype.body = function () { | ||
return this.source.skip(1); | ||
} | ||
function init(opts) { | ||
var source = new HttpObservable(opts); | ||
var published = source.publish(); | ||
return { | ||
get: function () { | ||
opts.method = 'GET'; | ||
published.connect(); | ||
return new Response(published); | ||
}, | ||
post: function () { | ||
opts.method = 'POST'; | ||
published.connect(); | ||
return new Response(published); | ||
}, | ||
request: function () { | ||
published.connect(); | ||
return new Response(published); | ||
} | ||
} | ||
} | ||
module.exports = init; |
{ | ||
"name": "http-observable", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "Node.js http module binding using the Reactive Extensions for JavaScript (RxJS) Observable to handle stream http response", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -11,3 +11,3 @@ # http-observable | ||
- SSL validations | ||
- Socket and connect timeout implementations | ||
- Socket and connect timeout implementations | ||
@@ -35,4 +35,5 @@ ## Install | ||
new HttpObservable(options) | ||
.subscribe( | ||
var response = HttpObservable(options).request(); | ||
response.body().subscribe( | ||
function onNext(chunk) { | ||
@@ -39,0 +40,0 @@ //Write the data chunk to response stream (Or process the data) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5858
64
60