@@ -1014,7 +1014,8 @@ Request.prototype._end = function() {
1014
1014
1015
1015
const max = this . _maxRedirects ;
1016
1016
const mime = utils . type ( res . headers [ 'content-type' ] || '' ) || 'text/plain' ;
1017
- const type = mime . split ( '/' ) [ 0 ] ;
1017
+ let type = mime . split ( '/' ) [ 0 ] ;
1018
+ if ( type ) type = type . toLowerCase ( ) . trim ( ) ;
1018
1019
const multipart = type === 'multipart' ;
1019
1020
const redirect = isRedirect ( res . statusCode ) ;
1020
1021
const responseType = this . _responseType ;
@@ -1331,14 +1332,17 @@ methods.forEach(method => {
1331
1332
1332
1333
function isText ( mime ) {
1333
1334
const parts = mime . split ( '/' ) ;
1334
- const type = parts [ 0 ] ;
1335
- const subtype = parts [ 1 ] ;
1335
+ let type = parts [ 0 ] ;
1336
+ if ( type ) type = type . toLowerCase ( ) . trim ( ) ;
1337
+ let subtype = parts [ 1 ] ;
1338
+ if ( subtype ) subtype = subtype . toLowerCase ( ) . trim ( ) ;
1336
1339
1337
1340
return type === 'text' || subtype === 'x-www-form-urlencoded' ;
1338
1341
}
1339
1342
1340
1343
function isImageOrVideo ( mime ) {
1341
- const type = mime . split ( '/' ) [ 0 ] ;
1344
+ let type = mime . split ( '/' ) [ 0 ] ;
1345
+ if ( type ) type = type . toLowerCase ( ) . trim ( ) ;
1342
1346
1343
1347
return type === 'image' || type === 'video' ;
1344
1348
}
@@ -1354,7 +1358,7 @@ function isImageOrVideo(mime) {
1354
1358
function isJSON ( mime ) {
1355
1359
// should match /json or +json
1356
1360
// but not /json-seq
1357
- return / [ / + ] j s o n ( $ | [ ^ - \w ] ) / . test ( mime ) ;
1361
+ return / [ / + ] j s o n ( $ | [ ^ - \w ] ) / i . test ( mime ) ;
1358
1362
}
1359
1363
1360
1364
/**
0 commit comments