Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ public async Task AuthenticatedProxyTunnelRequest_PostAsyncWithNoCreds_Throws()
using (HttpClient client = CreateHttpClient(handler))
{
HttpRequestException e = await Assert.ThrowsAnyAsync<HttpRequestException>(async () => await client.PostAsync("https://nosuchhost.invalid", new StringContent(content)));
Assert.Contains("407", e.Message);
Assert.Contains(((int)HttpStatusCode.ProxyAuthenticationRequired).ToString(), e.Message);
#if !WINHTTPHANDLER_TEST
Assert.Equal(HttpStatusCode.ProxyAuthenticationRequired, e.StatusCode);
Assert.Equal(HttpRequestError.ProxyTunnelError, e.HttpRequestError);
#endif
}
}
}
Expand All @@ -313,7 +317,11 @@ public async Task Proxy_SslProxyUnsupported_Throws()
{
handler.Proxy = new WebProxy($"https://{Guid.NewGuid():N}");

await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync($"http://{Guid.NewGuid():N}"));
HttpRequestException e = await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync($"http://{Guid.NewGuid():N}"));
#if !WINHTTPHANDLER_TEST
Assert.Null(e.StatusCode);
Assert.Equal(HttpRequestError.ProxyTunnelError, e.HttpRequestError);
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ private async ValueTask<Stream> EstablishProxyTunnelAsync(bool async, Cancellati
if (tunnelResponse.StatusCode != HttpStatusCode.OK)
{
tunnelResponse.Dispose();
throw new HttpRequestException(HttpRequestError.ProxyTunnelError, SR.Format(SR.net_http_proxy_tunnel_returned_failure_status_code, _proxyUri, (int)tunnelResponse.StatusCode));
throw new HttpRequestException(HttpRequestError.ProxyTunnelError, SR.Format(SR.net_http_proxy_tunnel_returned_failure_status_code, _proxyUri, (int)tunnelResponse.StatusCode), statusCode: tunnelResponse.StatusCode);
}

try
Expand Down