File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -84,15 +84,22 @@ export class DefaultHttpClient extends HttpClient {
84
84
xhr . timeout = request . timeout ;
85
85
}
86
86
87
- xhr . onload = ( ) => {
88
- if ( request . abortSignal ) {
89
- request . abortSignal . onabort = null ;
90
- }
91
-
92
- if ( xhr . status >= 200 && xhr . status < 300 ) {
93
- resolve ( new HttpResponse ( xhr . status , xhr . statusText , xhr . response || xhr . responseText ) ) ;
94
- } else {
95
- reject ( new HttpError ( xhr . statusText , xhr . status ) ) ;
87
+ xhr . onreadystatechange = ( ) => {
88
+ if ( xhr . readyState === 4 ) {
89
+ if ( request . abortSignal ) {
90
+ request . abortSignal . onabort = null ;
91
+ }
92
+
93
+ // Some browsers report xhr.status == 0 when the
94
+ // response has been cut off or there's been a TCP FIN.
95
+ // Treat it like a 200 with no response.
96
+ if ( xhr . status === 0 ) {
97
+ resolve ( new HttpResponse ( 200 , null , null ) ) ;
98
+ } else if ( xhr . status >= 200 && xhr . status < 300 ) {
99
+ resolve ( new HttpResponse ( xhr . status , xhr . statusText , xhr . response || xhr . responseText ) ) ;
100
+ } else {
101
+ reject ( new HttpError ( xhr . statusText , xhr . status ) ) ;
102
+ }
96
103
}
97
104
} ;
98
105
You can’t perform that action at this time.
0 commit comments