Skip to content

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

Closed as not planned
@tipa

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

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