File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 1
1
import InstabugConstants from './InstabugConstants' ;
2
+ import { stringifyIfNotString } from './InstabugUtils' ;
2
3
3
4
export type ProgressCallback = ( totalBytesSent : number , totalBytesExpectedToSend : number ) => void ;
4
5
export type NetworkDataCallback = ( data : NetworkData ) => void ;
@@ -80,7 +81,12 @@ export default {
80
81
} ;
81
82
82
83
XMLHttpRequest . prototype . setRequestHeader = function ( header , value ) {
83
- network . requestHeaders [ header ] = typeof value === 'string' ? value : JSON . stringify ( value ) ;
84
+ // According to the HTTP RFC, headers are case-insensitive, so we convert
85
+ // them to lower-case to make accessing headers predictable.
86
+ // This avoid issues like failing to get the Content-Type header for a request
87
+ // because the header is set as 'Content-Type' instead of 'content-type'.
88
+ const key = header . toLowerCase ( ) ;
89
+ network . requestHeaders [ key ] = stringifyIfNotString ( value ) ;
84
90
originalXHRSetRequestHeader . apply ( this , [ header , value ] ) ;
85
91
} ;
86
92
You can’t perform that action at this time.
0 commit comments