Comparing version 0.3.2 to 0.3.3
0.3.3 / 2012-12-14 | ||
================== | ||
* support writeStream | ||
0.3.2 / 2012-11-08 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -46,2 +46,4 @@ /** | ||
* - {ReadStream} [stream]: read stream to sent. | ||
* - {WriteStream} [writeStream]: writable stream to save response data. | ||
* If you use this, callback's data should be null. | ||
* - {String} [type]: optional, could be GET | POST | DELETE | PUT, default is GET | ||
@@ -129,3 +131,9 @@ * - {String} [dataType]: optional, `text` or `json`, default is text | ||
var writeStream = args.writeStream; | ||
var req = httplib.request(options, function (res) { | ||
if (writeStream) { | ||
res.on('end', callback.bind(null, null, null, res)); | ||
return res.pipe(writeStream); | ||
} | ||
var chunks = [], size = 0; | ||
@@ -158,3 +166,3 @@ res.on('data', function (chunk) { | ||
}, timeout); | ||
req.on('error', function (err) { | ||
req.once('error', function (err) { | ||
if (!__err && err.name === 'Error') { | ||
@@ -166,5 +174,12 @@ err.name = 'RequestError'; | ||
if (writeStream) { | ||
writeStream.once('error', function (err) { | ||
__err = err; | ||
req.abort(); | ||
}); | ||
} | ||
if (args.stream) { | ||
args.stream.pipe(req); | ||
args.stream.on('error', function (err) { | ||
args.stream.once('error', function (err) { | ||
__err = err; | ||
@@ -171,0 +186,0 @@ req.abort(); |
{ | ||
"name": "urllib", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more.", | ||
@@ -5,0 +5,0 @@ "keywords": [ "urllib", "http", "urlopen", "curl", "wget" ], |
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
11815
173
6