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 @@ -827,6 +827,7 @@ bool HandleRedirect (HttpStatusCode redirectCode, HttpURLConnection httpConnecti
// what to do with the response

case HttpStatusCode.TemporaryRedirect: // 307
case HttpStatusCode.PermanentRedirect: // 308
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ public async Task ServerCertificateCustomValidationCallback_Redirects ()
Assert.IsTrue (result.IsSuccessStatusCode);
}

[Test]
public async Task AndroidMessageHandlerFollows308PermanentRedirect ()
{
int callbackCounter = 0;

var handler = new AndroidMessageHandler ();

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);
Assert.AreEqual ("https://www.microsoft.com/", result.RequestMessage.RequestUri.ToString ());
}

private async Task AssertRejectsRemoteCertificate (Func<Task> makeRequest)
{
// there is a difference between the exception that's thrown in the .NET build and the legacy Xamarin
Expand Down