Fixed iOS bug where resend = no body#88
Fixed iOS bug where resend = no body#88GeoffArmstrong wants to merge 1 commit intoanaisbetts:masterfrom
Conversation
On iOS, copying the stream a second time resulted in no body because the stream position would have been advanced. Using ReadAsByteArray prevents this problem, it's more parallel with Android, and the implementation is simpler overall.
|
Hm, both the old version and the new version don't check the cancellation token, and copying the request stream could be a long process. Can you make that ReadAsByteArray cancelable? You probably have to copy-paste the implementation and add cancellation. |
|
I'm just trying to fix a bug I ran into when implementing retry logic on transient failures. Resending a message worked fine in Android, but it was missing the body of the request in iOS. Since the Android code used ReadAsByteArray I figured it was a good solution. I'm not sure exactly what you want in terms of respecting cancellation tokens, as I'm not an expert at writing async code. Perhaps you could just merge it in and make the changes you're intending? |
|
@GeoffArmstrong Basically, instead of using the built-in ReadAsByteArrayAsync, create a new method: public Task<byte[]> ReadAsByteArrayCancellable(this HttpContent content, CancellationToken ct)
{
// Implement me, possibly using the code from https://github.com/mono/mono/blob/effa4c07ba850bedbe1ff54b2a5df281c058ebcb/mcs/class/System.Net.Http/System.Net.Http/HttpContent.cs#L158
}then it's as easy as just replacing your ReadAsByteArrayAsync with your version |
|
Do you just want to put another |
No, it's gotta be in the body of the ReadAsByteArrayAsync, we actually want to interrupt reading the stream |
7de225e to
63dfb1a
Compare
|
So I updated to version 2.3, and it still has this issue. If I resend the same HttpRequestMessage (because the last time I sent it it timed out), the content doesn't get sent properly. |
On iOS, copying the stream a second time resulted in no body because the
stream position would have been advanced. Using ReadAsByteArray prevents
this problem, it's more parallel with Android, and the implementation is
simpler overall.