Permalink
Browse files

v0.3.7

  • Loading branch information...
1 parent e4ad564 commit 290323e8ffa003e3172deb856e7ec901f1d7f828 @SaltwaterC committed Sep 22, 2011
Showing with 19 additions and 5 deletions.
  1. +3 −0 CHANGELOG.md
  2. +15 −4 lib/http-get.js
  3. +1 −1 package.json
View
@@ -1,3 +1,6 @@
+## v0.3.7
+ * Improves the stability of the gzip support. In some cases, broken servers prematurely close the connection for gzipped responses. The request is now reissued without the gzip support.
+
## v0.3.6
* Improved the stability of the fsync(2) wrapper. The ocasional ENOENT errors should dissapear now.
* Fixes the auto-prefix functionality: if the http:// or https:// is missing, then http:// is automatically prepended. Now it specifically checks for http:// or https://.
View
@@ -197,10 +197,21 @@ var get = function (options, file, cb, reqId) {
var aborted = false;
res.on('close', function () {
aborted = true;
- var err = new Error('The server prematurely closed the connection.');
- err.code = res.statusCode;
- err.headers = res.headers;
- cb(err);
+ if (res.headers['content-encoding'] == 'gzip') {
+ // retry the request without gzip
+ delete(options.headers['accept-encoding']);
+ options.nogzip = true;
+ if (file === null) {
+ get(options, cb, reqId);
+ } else {
+ get(options, file, cb, reqId);
+ }
+ } else {
+ var err = new Error('The server prematurely closed the connection.');
+ err.code = res.statusCode;
+ err.headers = res.headers;
+ cb(err);
+ }
});
if (file) {
var transfer = {ended: false};
View
@@ -1,6 +1,6 @@
{
"name": "http-get",
- "version": "0.3.6",
+ "version": "0.3.7",
"main": "./lib/http-get.js",
"description": "Simple to use node.js HTTP / HTTPS client for downloading remote files. Supports transparent gzip decoding.",
"engines": {

0 comments on commit 290323e

Please sign in to comment.