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:
+18
-18
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user