@@ -26,8 +26,8 @@ internal class HttpClient : WebClient
26
26
protected override WebRequest GetWebRequest ( Uri address )
27
27
{
28
28
WebRequest w = base . GetWebRequest ( address ) ;
29
- if ( Timeout . Milliseconds != 0 )
30
- w . Timeout = Timeout . Milliseconds ;
29
+ if ( Timeout . TotalMilliseconds != 0 )
30
+ w . Timeout = ( int ) Timeout . TotalMilliseconds ;
31
31
return w ;
32
32
}
33
33
}
@@ -196,24 +196,22 @@ public async Task MakeRequest(Batch batch)
196
196
watch . Stop ( ) ;
197
197
198
198
var response = ( HttpWebResponse ) ex . Response ;
199
- if ( response != null )
199
+ // response with null value means connection error
200
+ statusCode = ( response != null ) ? ( int ) response . StatusCode : 0 ;
201
+ if ( ( statusCode >= 500 && statusCode <= 600 ) || statusCode == 429 || statusCode == 0 )
200
202
{
201
- statusCode = ( int ) response . StatusCode ;
202
- if ( ( statusCode >= 500 && statusCode <= 600 ) || statusCode == 429 )
203
- {
204
- // If status code is greater than 500 and less than 600, it indicates server error
205
- // Error code 429 indicates rate limited.
206
- // Retry uploading in these cases.
207
- Thread . Sleep ( backoff ) ;
208
- backoff *= 2 ;
209
- continue ;
210
- }
211
- else if ( statusCode >= 400 )
212
- {
213
- responseStr = String . Format ( "Status Code {0}. " , statusCode ) ;
214
- responseStr += ex . Message ;
215
- break ;
216
- }
203
+ // If status code is greater than 500 and less than 600, it indicates server error
204
+ // Error code 429 indicates rate limited.
205
+ // Retry uploading in these cases.
206
+ Thread . Sleep ( backoff ) ;
207
+ backoff *= 2 ;
208
+ continue ;
209
+ }
210
+ else if ( statusCode >= 400 )
211
+ {
212
+ responseStr = String . Format ( "Status Code {0}. " , statusCode ) ;
213
+ responseStr += ex . Message ;
214
+ break ;
217
215
}
218
216
}
219
217
0 commit comments