Comparing version 1.0.1 to 1.0.2
@@ -455,3 +455,3 @@ var Promise, S, addErrorData, bhttpAPI, concatStream, createCookieJar, debug, doPayloadRequest, doRedirect, errors, formData, formFixArray, http, https, isStream, makeRequest, ofTypes, packageConfig, prepareCleanup, prepareDefaults, prepareOptions, preparePayload, prepareProtocol, prepareRequest, prepareSession, prepareUrl, processResponse, querystring, redirectGet, redirectUnchanged, stream, streamLength, toughCookie, urlUtil, util, _; | ||
doPayloadRequest = function(url, data, options) { | ||
doPayloadRequest = function(url, data, options, callback) { | ||
if (isStream(data)) { | ||
@@ -464,3 +464,3 @@ options.inputStream = data; | ||
} | ||
return this.request(url, options); | ||
return this.request(url, options, callback); | ||
}; | ||
@@ -540,3 +540,3 @@ | ||
options.method = "head"; | ||
return this.request(url, options); | ||
return this.request(url, options, callback); | ||
}, | ||
@@ -548,3 +548,3 @@ get: function(url, options, callback) { | ||
options.method = "get"; | ||
return this.request(url, options); | ||
return this.request(url, options, callback); | ||
}, | ||
@@ -556,3 +556,3 @@ post: function(url, data, options, callback) { | ||
options.method = "post"; | ||
return doPayloadRequest.bind(this)(url, data, options); | ||
return doPayloadRequest.bind(this)(url, data, options, callback); | ||
}, | ||
@@ -564,3 +564,3 @@ put: function(url, data, options, callback) { | ||
options.method = "put"; | ||
return doPayloadRequest.bind(this)(url, data, options); | ||
return doPayloadRequest.bind(this)(url, data, options, callback); | ||
}, | ||
@@ -572,3 +572,3 @@ patch: function(url, data, options, callback) { | ||
options.method = "patch"; | ||
return doPayloadRequest.bind(this)(url, data, options); | ||
return doPayloadRequest.bind(this)(url, data, options, callback); | ||
}, | ||
@@ -580,3 +580,3 @@ "delete": function(url, data, options, callback) { | ||
options.method = "delete"; | ||
return this.request(url, options); | ||
return this.request(url, options, callback); | ||
}, | ||
@@ -583,0 +583,0 @@ request: function(url, options, callback) { |
{ | ||
"name": "bhttp", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A sane HTTP client library for Node.js with Streams2 support.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -49,2 +49,4 @@ # bhttp | ||
A simple example: | ||
```javascript | ||
@@ -54,2 +56,26 @@ var bhttp = require("bhttp"); | ||
Promise.try(function() { | ||
return bhttp.get("http://icanhazip.com/"); | ||
}).then(function(response) { | ||
console.log("Your IP is:", response.body.toString()); | ||
}); | ||
``` | ||
... or, using nodebacks: | ||
```javascript | ||
var bhttp = require("bhttp"); | ||
bhttp.get("http://icanhazip.com/", {}, function(err, response) { | ||
console.log("Your IP is:", response.body.toString()); | ||
}); | ||
``` | ||
### Streaming | ||
Demonstrating both streaming responses and using a stream in form data for a request: | ||
```javascript | ||
var bhttp = require("bhttp"); | ||
Promise.try(function() { | ||
return bhttp.get("http://somesite.com/bigfile.mp4", {stream: true}); | ||
@@ -154,3 +180,3 @@ }).then(function(response) { | ||
* __body__: When `stream` is set to `false` (the default), this will contain the response body. This can be either a string or, in the case of a JSON response, a decoded JSON object. | ||
* __body__: When `stream` is set to `false` (the default), this will contain the response body. This can be either a Buffer or, in the case of a JSON response, a decoded JSON object. | ||
* __redirectHistory__: An array containing the redirect responses, if any, in chronological order. Response bodies are discarded by default; if you do not want this, use the `keepRedirectResponses` option. | ||
@@ -157,0 +183,0 @@ * __request__: The request configuration that was generated by `bhttp`. You probably don't need this. |
Sorry, the diff of this file is not supported yet
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
3133056
12
649
213