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

Prevent redirects #82

Open
uzhas-sovka opened this issue May 12, 2020 · 3 comments
Open

Prevent redirects #82

uzhas-sovka opened this issue May 12, 2020 · 3 comments

Comments

@uzhas-sovka
Copy link

How can I prevent redirects?
httpConfigRedirectCount = 1 -- single redirect, OK.
httpConfigRedirectCount = 0 -- zero redirects and Exception.
Can I ban redirects and avoid exception?..

My goal is to get "Location" header, it's present in response to first request. http-client reportedly holds all history of redirects, but it's strange to make 5 requests consequently with Req and the last with other tool.


Mark, thanks for your library, I managed to get it working. "Get it working" means not the quality of library, it's beyond questions, but the lack of my Haskell skills.

@mrkkrp
Copy link
Owner

mrkkrp commented May 18, 2020

I suppose you're talking about withResponseHistory. Indeed, there is nothing like that in Req.

I lack time to work on this.

@uzhas-sovka
Copy link
Author

I'd like to narrow the question, as was mentioned in initial post: can we prevent redirects and avoid exception?.. No need to hold all history.

@hughjfchen
Copy link

How can I prevent redirects?
httpConfigRedirectCount = 1 -- single redirect, OK.
httpConfigRedirectCount = 0 -- zero redirects and Exception.
Can I ban redirects and avoid exception?..

My goal is to get "Location" header, it's present in response to first request. http-client reportedly holds all history of redirects, but it's strange to make 5 requests consequently with Req and the last with other tool.

Mark, thanks for your library, I managed to get it working. "Get it working" means not the quality of library, it's beyond questions, but the lack of my Haskell skills.

If you want to get the "Location" header for the redirect after the first request, I think you can set the redirect count to 0 and handle the exception to extract the data from the response with the exception.

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

No branches or pull requests

3 participants