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

Make redirect history available #731

Closed
RossLote opened this issue Feb 16, 2024 · 6 comments
Closed

Make redirect history available #731

RossLote opened this issue Feb 16, 2024 · 6 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@RossLote
Copy link

I've been getting some strange redirect behaviour and I'd like a way to find out whet is happening. For the URL I'm fetching I've been getting a TooManyRedirects, message: Some("reached max redirects (5)") error.

I fetched the same URL using the python requests library and I only got 1 redirect so I think there may be a problem. I'm actually in charge of the entire stack and can assure you that there is only 1 redirect in the entire request cycle.

I've managed to get around it by setting the redirect limit to 6 but because I have no visibility of the history I can't find out what is going on.

Is there a reason the history is private?

@RossLote
Copy link
Author

Did anyone see this?

@algesten
Copy link
Owner

I don't really have an answer to why the history is private more than the smaller the API the less headache to maintain ureq.

@algesten algesten changed the title Redirect history not available Make redirect history available Nov 26, 2024
@algesten algesten added help wanted Extra attention is needed good first issue Good for newcomers labels Nov 26, 2024
@algesten
Copy link
Owner

I welcome help on this for ureq 3.x.

  • A new config option that is false by default.
  • Collect each redirect location into a Vec
  • Make Vec available through ResponseExt trait.

@thkoch2001
Copy link

thkoch2001 commented Dec 27, 2024

I'm moving from reqwest to ureq to get rid of async.
Reqwest provides me with an url() method for the final url after redirects:
https://docs.rs/reqwest/latest/reqwest/struct.Response.html#method.url

I'd need just the final url, but the full history is of course also a solution.

UPDATE: I'm writing a crawler for a search engine and web archive[¹]. I'll just set max_redirects to 0 and handle them in my code, putting the redirect URL back in the crawler queue and incrementing the crawl depth counter of the url.

Maybe the full history could be collected by a middleware?

[1:] https://github.com/thkoch2001/lara

@algesten
Copy link
Owner

I'd need just the final url, but the full history is of course also a solution.

This is actually already implemented in the latest RC. https://docs.rs/ureq/3.0.0-rc3/ureq/trait.ResponseExt.html#tymethod.get_uri

@algesten
Copy link
Owner

Closed by #939

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants