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 @@ -286,12 +286,17 @@ public void Redirect_POST_With_Content_Works ()
}
}

void EnsureSuccessStatusCode (HttpResponseMessage response)
public void EnsureSuccessStatusCode (HttpResponseMessage response)
{
// If we hit a 502 (which is quite common on CI) just ignore the test
if (response.StatusCode == HttpStatusCode.BadGateway) {
Assert.Ignore ($"Ignoring network failure: {response.StatusCode}");
return;
// These status codes all indicate a temporary network/server failure,
// so just ignore the test if we hit them.
switch (response.StatusCode) {
case HttpStatusCode.InternalServerError:
case HttpStatusCode.BadGateway:
case HttpStatusCode.ServiceUnavailable:
case HttpStatusCode.GatewayTimeout:
Assert.Ignore ($"Ignoring network/server failure: {response.StatusCode}");
return;
}

response.EnsureSuccessStatusCode ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ public async Task ServerCertificateCustomValidationCallback_Redirects ()
var client = new HttpClient (handler);
var result = await client.GetAsync ("https://httpbin.org/redirect-to?url=https://www.microsoft.com/");

EnsureSuccessStatusCode (result);

Assert.AreEqual (2, callbackCounter);
Assert.IsTrue (result.IsSuccessStatusCode);
}

[Test]
Expand All @@ -245,7 +246,8 @@ public async Task AndroidMessageHandlerFollows308PermanentRedirect ()
var client = new HttpClient (handler);
var result = await client.GetAsync ("https://httpbin.org/redirect-to?url=https://www.microsoft.com/&status_code=308");

Assert.IsTrue (result.IsSuccessStatusCode);
EnsureSuccessStatusCode (result);

Assert.AreEqual ("https://www.microsoft.com/", result.RequestMessage.RequestUri.ToString ());
}

Expand Down
Loading