Skip to content

AndroidClientHandler: Return 308 response code to client instead of throwing exception #4477

Description

@tipa

Steps to Reproduce

  1. Use Google APIs Client Library for .NET
  2. Configure the library to use the AndroidClientHandler instead of the default HttpClientHandler by subclassing HttpClientFactory
  3. Uploade file with resumable upload
  4. In some cases Google Drive returns error code 308 Resume Incomplete (which is usually 308 Permanent Redirect) to indicate that an incomplete upload has stalled

Expected Behavior

Return the response code to the client so it can be handled like from the Google APIs Library here

Actual Behavior

System.InvalidOperationException: HTTP Redirection status code PermanentRedirect (308) not supported
  at Xamarin.Android.Net.AndroidClientHandler.HandleRedirect (System.Net.HttpStatusCode redirectCode, Java.Net.HttpURLConnection httpConnection, Xamarin.Android.Net.AndroidClientHandler+RequestRedirectionState redirectState, System.Boolean& disposeRet) <0x7237a0dc20 + 0x00384> in <6071f7bd4f0c4adf848cbcbba2dc27fe>:0 
  at Xamarin.Android.Net.AndroidClientHandler.DoProcessRequest (System.Net.Http.HttpRequestMessage request, Java.Net.URL javaUrl, Java.Net.HttpURLConnection httpConnection, System.Threading.CancellationToken cancellationToken, Xamarin.Android.Net.AndroidClientHandler+RequestRedirectionState redirectState) [0x00552] in <6071f7bd4f0c4adf848cbcbba2dc27fe>:0 
  at Xamarin.Android.Net.AndroidClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x7237a0fe7c + 0x00657> in <6071f7bd4f0c4adf848cbcbba2dc27fe>:0 
  at Google.Apis.Http.ConfigurableMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00681] in <5c06fc9cf97c400ea14364d81accc883>:0 
  at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in <ea2d1c6f7b4d4daba354b37d249494a8>:0 
  at Google.Apis.Upload.ResumableUpload.SendNextChunkAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) <0x723524b2fc + 0x0051f> in <089d88fa5ccb4f7abc33a244904740b6>:0 

I also reported this problem here but I feel like this problem likely has to be taken care of on the Xamarin-side, possible in the same switch-case as already been done for response code 304 here

Activity

  1. tarvy commented on Oct 7, 2021

    @tarvy

    Any word on when this change will be made?
    Having the 308 return a system exception is pretty troublesome.

  2. added
    Area: HTTPIssues with sockets / HttpClient.
    and removed on Sep 6, 2022
  3. jpobst commented on May 13, 2024

    @jpobst
    Contributor

    With support for Classic Xamarin.Android ended May 1st, 2024, this issue is likely no longer relevant.

    If this still persists in .NET 8+, please open a new issue with updated information based on net8.0-android or greater. Please include a link to this issue for context.

  4. locked and limited conversation to collaborators on Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: HTTPIssues with sockets / HttpClient.enhancementProposed change to current functionality.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions