Skip to content
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

URLSession: Fix redirection response handling #2744

Merged
merged 1 commit into from
Mar 25, 2020

Conversation

spevans
Copy link
Contributor

@spevans spevans commented Mar 25, 2020

  • 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.

- 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.
@spevans
Copy link
Contributor Author

spevans commented Mar 25, 2020

@swift-ci test linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant