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

Add redirect support for ASIO client #373

Closed
wants to merge 1 commit into from

Conversation

8W9aG
Copy link

@8W9aG 8W9aG commented Mar 2, 2017

  • Add a checking task that determines whether to
    launch a new request with the redirection
  • Adheres to RFC-2068 10.3 by not allowing more than
    5 redirects
  • Does not allow redirect loops

Let me know if this approach is sound, if so then I will make tests.

* Add a checking task that determines whether to
launch a new request with the redirection
* Adheres to RFC-2068 10.3 by not allowing more than
5 redirects
* Does not allow redirect loops
@8W9aG
Copy link
Author

8W9aG commented Mar 8, 2017

@stgates would it be possible to give this a little looksee?

@mobileben
Copy link
Contributor

Just curious on this. What happens for any exceptions generated? I've found that when using the .then, exceptions can't be caught. I haven't overly looked at the code for pplx. What I've had to do in my stuff is wrap the call in std::async in order to prevent a SIGTRAP. For example, a simple network error, if you don't do this, will crash the client due to an uncaught exception.

}

pplx::task<http_response> asio_client::maybe_redirect(http_response response, http_request request, std::vector<uri> redirected_uris) {
static const status_code found_status_code = 302;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constant is already defined here: web::http::status_codes::Found

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt we also react to:

  • 301 Moved Permanently
  • 307 Temporary Redirect
  • 308 Permanent Redirect

Copy link
Contributor

@garethsb garethsb Feb 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes (with the rules for only redirecting GET and HEAD taken into account). Also, the PR code comments refer to RFC 2068, which has been obsoleted twice-over, with RFC 7231 section 6.4 being the most recent spec I believe. This spec also removes the arbitrary maximum redirect count of 5 and explicitly recommends identifying cycles.

@microsoft microsoft deleted a comment from msftclas Sep 27, 2017
@8W9aG 8W9aG closed this May 21, 2018
@garethsb
Copy link
Contributor

If this were to be added, it would be good to add to http_client_config a common setting that would enable/disable this behaviour in both ASIO and WinHttp implementations (for the latter, see #171)

@garethsb
Copy link
Contributor

garethsb commented Feb 13, 2020

Specifically, config support could be made common for:

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.

None yet

6 participants