2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Using more strict eslint rules

This commit is contained in:
Matt Zabriskie
2015-12-14 20:06:57 -07:00
parent 2b147fb0b7
commit f28a4a8248
16 changed files with 230 additions and 93 deletions
+18 -18
View File
@@ -68,35 +68,35 @@ module.exports = function httpAdapter(resolve, reject, config) {
// Create the request
var transport = parsed.protocol === 'https:' ? https : http;
var req = transport.request(options, function (res) {
var req = transport.request(options, function handleResponse(res) {
// uncompress the response body transparently if required
var stream = res;
switch(res.headers['content-encoding']) {
case 'gzip':
case 'compress':
case 'deflate': {
// add the unzipper to the body stream processing pipeline
stream = stream.pipe(zlib.createUnzip());
switch (res.headers['content-encoding']) {
/*eslint default-case:0*/
case 'gzip':
case 'compress':
case 'deflate':
// add the unzipper to the body stream processing pipeline
stream = stream.pipe(zlib.createUnzip());
// remove the content-encoding in order to not confuse downstream operations
delete res.headers['content-encoding'];
}
// remove the content-encoding in order to not confuse downstream operations
delete res.headers['content-encoding'];
break;
}
var responseBuffer = [];
stream.on('data', function (chunk) {
stream.on('data', function handleStreamData(chunk) {
responseBuffer.push(chunk);
});
stream.on('end', function () {
var data = Buffer.concat(responseBuffer);
stream.on('end', function handleStreamEnd() {
var d = Buffer.concat(responseBuffer);
if (config.responseType !== 'arraybuffer') {
data = data.toString('utf8');
d = d.toString('utf8');
}
var response = {
data: transformData(
data,
d,
res.headers,
config.transformResponse
),
@@ -114,12 +114,12 @@ module.exports = function httpAdapter(resolve, reject, config) {
});
// Handle errors
req.on('error', function (err) {
req.on('error', function handleRequestError(err) {
reject(err);
});
// Handle request timeout
req.setTimeout(config.timeout, function () {
req.setTimeout(config.timeout, function handleRequestTimeout() {
req.abort();
});