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

Get final redirected URL from response #293

Closed
drishit96 opened this issue Aug 12, 2019 · 8 comments · Fixed by #1109
Closed

Get final redirected URL from response #293

drishit96 opened this issue Aug 12, 2019 · 8 comments · Fixed by #1109

Comments

@drishit96
Copy link

When followRedirects is set to true for a GET request, there seems to be know way to know the final redirected URL.
An issue that reports this: https://stackoverflow.com/questions/56861837/how-to-get-redirect-url-in-dart-flutter

The request package for Node.js provides a solution like this:
https://stackoverflow.com/a/34600159/5987223

This would be useful when expanding a shortened link

@YizhePKU
Copy link

YizhePKU commented Sep 15, 2019

I've made a pull request #321 .
If it is accepted and merged, you should be able to access final redirected URL with response.url.

@clragon
Copy link

clragon commented Apr 14, 2020

this is still a problem, I am having it right now.

@YizhePKU
Copy link

@clragon Unfortunately my pull request went unnoticed. I'm no longer working on this. If you really want to get this working, the best you can do is to fork the repo and patch it yourself. You can refer to my pull request; the modification is really trivial.

@VigneshKalavakuri
Copy link

VigneshKalavakuri commented Jun 14, 2021

How to get redirected url from http

If a website abc.com redirects jkl.com and jkl.com redirects to xyz.com (Current website)

How to get the current website url xyz.com from http package

@othnielussher
Copy link

@Ronaldo7Messi10 did you find a solution yet?

@othnielussher
Copy link

@YizhePKU Can you please share the patch you prepared? The link to the pull request seems to be broken.

@YizhePKU
Copy link

Alas, I've long forgotten about this and have deleted my repo. The content of the patch is still viewable here. You may need to recreate the patch yourself.

@othnielussher
Copy link

@YizhePKU Thank you

natebosch added a commit that referenced this issue May 25, 2022
Closes #321, closes #623, closes #692
Fixes #293

Add a Uri field to BaseResponse with the final, potentially redirected,
url for the content.

The field is nullable for backwards compatibility - TODO: consider if
this should be non-nullable from the start, or if it can be published
nullable first and become non-nullable (and the constructor arg
required) in the next breaking release.

This may break tests which use bocks but do not mock the field used to
read the URL.
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 a pull request may close this issue.

5 participants