@@ -14,7 +14,7 @@ export class DefaultSubmissionAdapter implements ISubmissionAdapter {
14
14
15
15
let isCompleted : boolean = false ;
16
16
let useSetTimeout : boolean = false ;
17
- function complete ( mode : string , xhr : XMLHttpRequest ) {
17
+ function complete ( mode : string , xhrRequest : XMLHttpRequest ) {
18
18
function parseResponseHeaders ( headerStr ) {
19
19
function trim ( value ) {
20
20
return value . replace ( / ^ [ \s \uFEFF \xA0 ] + | [ \s \uFEFF \xA0 ] + $ / g, '' ) ;
@@ -40,17 +40,17 @@ export class DefaultSubmissionAdapter implements ISubmissionAdapter {
40
40
41
41
isCompleted = true ;
42
42
43
- let message : string = xhr . statusText ;
44
- const responseText : string = xhr . responseText ;
45
- let status : number = xhr . status ;
43
+ let message : string = xhrRequest . statusText ;
44
+ const responseText : string = xhrRequest . responseText ;
45
+ let status : number = xhrRequest . status ;
46
46
47
47
if ( mode === TIMEOUT || status === 0 ) {
48
48
message = 'Unable to connect to server.' ;
49
49
status = 0 ;
50
50
} else if ( mode === LOADED && ! status ) {
51
51
status = request . method === 'POST' ? 202 : 200 ;
52
52
} else if ( status < 200 || status > 299 ) {
53
- const responseBody : any = ( xhr as any ) . responseBody ;
53
+ const responseBody : any = ( xhrRequest as any ) . responseBody ;
54
54
if ( ! ! responseBody && ! ! responseBody . message ) {
55
55
message = responseBody . message ;
56
56
} else if ( ! ! responseText && responseText . indexOf ( 'message' ) !== - 1 ) {
@@ -62,31 +62,31 @@ export class DefaultSubmissionAdapter implements ISubmissionAdapter {
62
62
}
63
63
}
64
64
65
- callback && callback ( status || 500 , message || '' , responseText , parseResponseHeaders ( xhr . getAllResponseHeaders && xhr . getAllResponseHeaders ( ) ) ) ;
65
+ callback && callback ( status || 500 , message || '' , responseText , parseResponseHeaders ( xhrRequest . getAllResponseHeaders && xhrRequest . getAllResponseHeaders ( ) ) ) ;
66
66
}
67
67
68
- function createRequest ( userAgent : string , method : string , url : string ) : XMLHttpRequest {
69
- let xhr : any = new XMLHttpRequest ( ) ;
70
- if ( WITH_CREDENTIALS in xhr ) {
71
- xhr . open ( method , url , true ) ;
68
+ function createRequest ( userAgent : string , method : string , uri : string ) : XMLHttpRequest {
69
+ let xmlRequest : any = new XMLHttpRequest ( ) ;
70
+ if ( WITH_CREDENTIALS in xmlRequest ) {
71
+ xmlRequest . open ( method , uri , true ) ;
72
72
73
- xhr . setRequestHeader ( 'X-Exceptionless-Client' , userAgent ) ;
73
+ xmlRequest . setRequestHeader ( 'X-Exceptionless-Client' , userAgent ) ;
74
74
if ( method === 'POST' ) {
75
- xhr . setRequestHeader ( 'Content-Type' , 'application/json' ) ;
75
+ xmlRequest . setRequestHeader ( 'Content-Type' , 'application/json' ) ;
76
76
}
77
77
} else if ( typeof XDomainRequest !== 'undefined' ) {
78
78
useSetTimeout = true ;
79
- xhr = new XDomainRequest ( ) ;
80
- xhr . open ( method , location . protocol === 'http:' ? url . replace ( 'https:' , 'http:' ) : url ) ;
79
+ xmlRequest = new XDomainRequest ( ) ;
80
+ xmlRequest . open ( method , location . protocol === 'http:' ? uri . replace ( 'https:' , 'http:' ) : uri ) ;
81
81
} else {
82
- xhr = null ;
82
+ xmlRequest = null ;
83
83
}
84
84
85
- if ( xhr ) {
86
- xhr . timeout = 10000 ;
85
+ if ( xmlRequest ) {
86
+ xmlRequest . timeout = 10000 ;
87
87
}
88
88
89
- return xhr ;
89
+ return xmlRequest ;
90
90
}
91
91
92
92
const url = `${ request . url } ${ ( request . url . indexOf ( '?' ) === - 1 ? '?' : '&' ) } access_token=${ encodeURIComponent ( request . apiKey ) } ` ;
0 commit comments