URLSession: Fix redirection response handling #2744
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
300 Multiple Choices: Do not follow the redirect, just return the body
from the response. However HEAD requests return no body.
301 Moved Permanently, 302 Found: Follow the redirect but send POST
requests as GET when following the redirect.
303 See Other: Follow the redirect but always send the request to the
new Location as a GET.
304 Not Modified: No special handling or redirects to follow since the
server decides whether to send a response based on the request headers
If-Modified-Since or If-None-Match.
305 Use Proxy, 306 Switch Proxy, 307 Temporary Redirect,
308 Permanent Redirect:
Follow the redirection but do not change the method, just repeat the
request to the new location.
This fix applies for valid redirections in the range 300-308, other
3xx codes have no specific support.
Redirection handling should now match Darwin more closely.
Resolves SR-2679: URLSession delivers redirection delegate methods
in the wrong order.
SR-11673: URLSession download task merges redirect responses.