Skip to content

Commit

Permalink
Merge pull request assaf#37 from philipheinser/patch-1
Browse files Browse the repository at this point in the history
Unzip Remote Images If Content-Encoding is "gzip"
  • Loading branch information
assaf committed May 12, 2015
2 parents b4bdbaf + 5d8cf7b commit 3623c34
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var HTTP = require("http");
var HTTPS = require("https");
var Path = require("path");
var Zip = require("./zip");
var zlib = require("zlib");


// Top-level pass fields.
Expand Down Expand Up @@ -298,7 +299,11 @@ function addImage(file, source, callback) {
protocol.get(source, function(response) {
if (response.statusCode == 200) {
file.on("close", callback);
response.pipe(file);
if (response.headers['content-encoding'] === "gzip") {
response.pipe(zlib.createGunzip()).pipe(file);
} else {
response.pipe(file);
}
response.resume();
} else
callback(new Error("Server returned " + response.statusCode + " for " + source));
Expand Down

0 comments on commit 3623c34

Please sign in to comment.