Skip to content

Commit 484dfff

Browse files
committed
Improved HttpRequest.GetResponse exception handling
1 parent 5033a6f commit 484dfff

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/Skybrud.Essentials.Http/HttpRequest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,14 @@ public virtual IHttpResponse GetResponse(Action<HttpWebRequest> callback) {
435435

436436
#endif
437437

438+
} catch (AggregateException ex) {
439+
440+
if (ex.InnerException is WebException web && web.Status == WebExceptionStatus.ProtocolError) {
441+
return HttpResponse.GetFromWebResponse(web.Response as HttpWebResponse, this);
442+
}
443+
444+
throw;
445+
438446
} catch (WebException ex) {
439447
if (ex.Status != WebExceptionStatus.ProtocolError) throw;
440448
return HttpResponse.GetFromWebResponse(ex.Response as HttpWebResponse, this);

0 commit comments

Comments
 (0)