Skip to content

Commit 77a2439

Browse files
committed
Propagate connect failures et al. upwards to avoid crashing later with a nullref in Http.ExtractResponseData
1 parent cde17e8 commit 77a2439

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

RestSharp/Http.Async.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,13 @@ private static void GetRawResponseAsync(IAsyncResult result, Action<HttpWebRespo
266266
if(ex.Status == WebExceptionStatus.RequestCanceled)
267267
{
268268
throw ex;
269-
}
270-
269+
}
271270
if (ex.Response is HttpWebResponse)
272271
{
273272
raw = ex.Response as HttpWebResponse;
273+
} else
274+
{
275+
throw ex;
274276
}
275277
}
276278

@@ -304,7 +306,15 @@ private void ResponseCallback(IAsyncResult result, Action<HttpResponse> callback
304306
response.ResponseStatus = ResponseStatus.Aborted;
305307
ExecuteCallback(response, callback);
306308
return;
309+
} else
310+
{
311+
response.ErrorMessage = ex.Message;
312+
response.ErrorException = ex;
313+
response.ResponseStatus = ResponseStatus.Error;
314+
ExecuteCallback(response, callback);
315+
return;
307316
}
317+
308318
}
309319
catch(Exception ex)
310320
{

0 commit comments

Comments
 (0)