-
Notifications
You must be signed in to change notification settings - Fork 519
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
NSUrlSessionHandler: Rewind request content to the start before sending #16341
Conversation
Thanks for this I was looking into this. We need to add a test case before we land this. |
I agree, can you help me with this: As I see the right place to add tests is here: I tried to run |
@wcoder I will take care of this and will push a test example to this branch. We can later agree on my tests :) |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@microsoft-github-policy-service agree |
if (stream.CanSeek) | ||
stream.Seek(0, SeekOrigin.Begin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't assume that the thing I want to send is from the beginning of the stream. If I do a partial upload of a file (ie resumed upload), I'd have an offset in my filestream. Instead rewind to where the request was originally meant to start from, and definitely only on an automated retry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that described behavior has been supported before. Do you have an example?
As I can see, the current implementation of NSUrlSessionHandler
uses simple NSURLSessionDataTask
under the hood. If you need specific upload a file you should be sure that the native layer supports this behavior.
There is NSURLSessionUploadTask in iOS for upload but we can't simply use it without reworking the native handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need specific upload a file you should be sure that the native layer
I don't see why I need to do that. The normal http handlers does this just fine. Regardless, you're posting some stream,. and it's wrong to assume it's from the beginning of that stream, and that was all I was pointing out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is true then the behaviour in the android equivalent of this class is wrong. See: AndroidMessageHandler.cs
if (stream.CanSeek)
stream.Seek (0, SeekOrigin.Begin);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup it would seem so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think doing the same thing Android does is good enough for now, it's still better than the previous behavior.
I'm going to block this since I want to get input from the dotnet team, I'll me looking at how the socket handler is implemented too. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
👀 |
@mandel-macaque Hi, Do you have some updates? |
@mandel-macaque Do you have any updates? |
Any news on this? This breaks the Polly retry library. |
@DuncaMT bumping this in my todo, I'll take care of it ASAP. |
Hi @mandel-macaque, sorry to bother you. May you have some time to review this PR? |
Hi @{issueAuthor}. Due to inactivity, we will close this pull request in 7 days. |
Hi @{issueAuthor}. This pull request was closed due to inactivity. Please let us know if you'd like to reopen it. |
@mandel-macaque Could you please reopen this PR? @microsoft-github-policy-service bot looks too buggy |
Would love to see some progress on this PR, since now the AndroidMessageHandler is also being fixed that already had stream rewind logic: |
|
Agreed. This would be some awesome cleanup that'll improve our retry logic as well and save some ugly byte array copying to ensure things are retriable |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
💻 [CI Build] Windows Integration Tests passed 💻✅ All Windows Integration Tests passed. Pipeline on Agent |
💻 [PR Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
📚 [PR Build] Artifacts 📚Packages generatedView packagesPipeline on Agent |
💻 [PR Build] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [PR Build] Tests on macOS M1 - Mac Big Sur (11) passed 💻✅ All tests on macOS M1 - Mac Big Sur (11) passed. Pipeline on Agent |
💻 [PR Build] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes)
NET (empty diffs)
✅ API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🚀 [CI Build] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 170 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Fixes #16339