Permalink
Browse files

Merge branch 'future'

  • Loading branch information...
2 parents 511bb04 + e22d9ec commit 40e86e97929314f29d9785f1984b11d110f4e4b1 @SaltwaterC committed Jun 20, 2012
Showing with 32 additions and 7 deletions.
  1. +3 −0 CHANGELOG.md
  2. +1 −1 README.md
  3. +1 −1 lib/http-get.js
  4. +1 −1 package.json
  5. +11 −0 tests/includes/common.js
  6. +15 −4 tests/response-file-null.js
View
@@ -1,3 +1,6 @@
+## v0.4.2
+ * Fixes the null as file argument when the response is a redirect. The body of the response was buffered instead of being discarded.
+
## v0.4.1
* Passing null as the file argument to http.get turns off saving the response body.
* Fixes the HTTP Basic authentication support. [#9](https://github.com/SaltwaterC/http-get/issues/9)
View
@@ -23,7 +23,7 @@ Either manually clone this repository into your node_modules directory, or the r
This library is not recommended under node.js v0.6.17 due to [this issue](https://groups.google.com/forum/#!topic/nodejs/6euYfwMmx1Y).
-node.js v0.4 is **NOT** supported due to lack of zlib bindings. Only http-get v0.3 versions supports node.js v0.4.
+node.js v0.4 is **NOT** supported due to lack of zlib bindings. node.js v0.4 is only supported by the http-get v0.3 versions.
## Contributor
View
@@ -299,7 +299,7 @@ var get = function (options, file, cb, reqId) {
} else {
options.url = tools.prepareRedirectUrl(url, res.headers.location);
if (reqId < options.redirects) {
- if ( ! file) {
+ if (file === false) {
file = cb;
}
get(options, file, cb, reqId);
View
@@ -1,6 +1,6 @@
{
"name": "http-get",
- "version": "0.4.1",
+ "version": "0.4.2",
"main": "./lib/http-get.js",
"description": "Simple to use node.js HTTP / HTTPS client for downloading remote files. Supports transparent gzip / deflate decoding.",
"dependencies": {
View
@@ -20,6 +20,13 @@ options.url = u.format({
pathname: '/'
});
+options.urlRedirect = u.format({
+ protocol: 'http:',
+ hostname: options.host,
+ port: options.port,
+ pathname: '/redirect'
+});
+
options.url404 = u.format({
protocol: 'http:',
hostname: options.host,
@@ -140,6 +147,10 @@ var createFooServer = function (secure, cb) {
}
break;
+ case '/redirect':
+ res.writeHead(302, {location: options.url});
+ break;
+
default:
res.writeHead(200, {'content-type': 'text/plain'});
break;
@@ -3,18 +3,29 @@ var http = require('../');
var assert = require('assert');
var common = require('./includes/common.js');
-var callback = false;
+var callback = {
+ direct: false,
+ redirect: false
+};
var server = common.createFooServer(false, function () {
http.get({url: common.options.url}, null, function (err, res) {
- callback = true;
+ callback.direct = true;
assert.ifError(err);
assert.deepEqual(200, res.code);
assert.ok(res.headers);
- server.close();
+ http.get({url: common.options.urlRedirect}, null, function (err, res) {
+ callback.redirect = true;
+ assert.ifError(err);
+ assert.deepEqual(200, res.code);
+ assert.ok(res.headers);
+ server.close();
+ });
});
});
process.on('exit', function () {
- assert.ok(callback);
+ for (var i in callback) {
+ assert.ok(callback[i]);
+ }
});

0 comments on commit 40e86e9

Please sign in to comment.