mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
add test cases for compressed response
This commit is contained in:
@@ -242,18 +242,16 @@ class Recorder extends events.EventEmitter {
|
||||
bodyContent = iconv.decode(bodyContent, currentCharset);
|
||||
}
|
||||
|
||||
result.mime = contentType;
|
||||
result.content = bodyContent.toString();
|
||||
result.type = contentType && /application\/json/i.test(contentType) ? 'json' : 'text';
|
||||
} else if (contentType && /image/i.test(contentType)) {
|
||||
result.type = 'image';
|
||||
result.mime = contentType;
|
||||
result.content = bodyContent;
|
||||
} else {
|
||||
result.type = contentType;
|
||||
result.mime = contentType;
|
||||
result.content = bodyContent.toString();
|
||||
}
|
||||
result.mime = contentType;
|
||||
result.fileName = path.basename(record.path);
|
||||
result.statusCode = record.statusCode;
|
||||
} catch (e) {
|
||||
|
||||
@@ -146,10 +146,8 @@ class webInterface extends events.EventEmitter {
|
||||
if (err || !result) {
|
||||
res.json({});
|
||||
} else if (result.statusCode === 200 && result.mime) {
|
||||
if (result.type === 'json' ||
|
||||
result.mime.indexOf('text') === 0 ||
|
||||
// deal with 'application/x-javascript' and 'application/javascript'
|
||||
result.mime.indexOf('javascript') > -1) {
|
||||
// deal with 'application/x-javascript' and 'application/javascript'
|
||||
if (/json|text|javascript/.test(result.mime)) {
|
||||
_resContent();
|
||||
} else if (result.type === 'image') {
|
||||
_resDownload(false);
|
||||
|
||||
Reference in New Issue
Block a user