Skip to content

Commit

Permalink
Revert "Merge pull request #111 from gmetais/devel"
Browse files Browse the repository at this point in the history
This reverts commit a9b8c95, reversing
changes made to 18d0923.

Conflicts:
	lib/runner.js
  • Loading branch information
macbre committed Apr 16, 2016
1 parent e1f9c67 commit 7eb407f
Showing 1 changed file with 10 additions and 60 deletions.
70 changes: 10 additions & 60 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ var cli = require('cli'),
resolve = require('path').resolve,
analyzer = require('./index'),
preprocessors = new(require('./preprocessors'))(),
url = require('url'),
zlib = require('zlib');
url = require('url');

/**
* Return user agent to be used by analyze-css when making HTTP requests (issue #75)
Expand Down Expand Up @@ -46,63 +45,15 @@ function request(requestOptions, callback) {

client.get(requestOptions, function(resp) {
var out = '';
resp.on('data', function(chunk) {
out += chunk;
});

switch (resp.headers['content-encoding']) {
case 'gzip':
var gzip = zlib.createGunzip();

gzip.on('data', function(chunk) {
out += chunk;
});

gzip.on('end', function() {
debug('HTTP %d', resp.statusCode);
debug('Headers: %j', resp.headers);
callback(null, resp, out);
});

gzip.on('error', function(err) {
err = new Error('Error while decoding ' + requestOptions.href + ': ' + err.toString());
callback(err);
});

resp.pipe(gzip);

break;
case 'deflate':
var deflate = zlib.createInflate();

deflate.on('data', function(chunk) {
out += chunk;
});

deflate.on('end', function() {
debug('HTTP %d', resp.statusCode);
debug('Headers: %j', resp.headers);
callback(null, resp, out);
});

gzip.on('error', function(err) {
err = new Error('Error while decoding ' + requestOptions.href + ': ' + err.toString());
callback(err);
});

resp.pipe(deflate);

break;
default:
resp.on('data', function(chunk) {
out += chunk;
});

resp.on('end', function() {
debug('HTTP %d', resp.statusCode);
debug('Headers: %j', resp.headers);
callback(null, resp, out);
});

break;
}
resp.on('end', function() {
debug('HTTP %d', resp.statusCode);
debug('Headers: %j', resp.headers);
callback(null, resp, out);
});
}).on('error', function(err) {
debug(err);
callback(err);
Expand All @@ -129,8 +80,7 @@ function runner(options, callback) {
var requestOptions = url.parse(options.url);
requestOptions.rejectUnauthorized = !options.ignoreSslErrors;
requestOptions.headers = {
'User-Agent': getUserAgent(),
'Accept-Encoding': 'gzip, deflate'
'User-Agent': getUserAgent()
};

if (options.authUser && options.authPass) {
Expand Down

0 comments on commit 7eb407f

Please sign in to comment.