Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mono.Android] AndroidMessageHandler should follow 308: permanent redirect #8951

Merged
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