req icon indicating copy to clipboard operation
req copied to clipboard

Prevent redirects

Open uzhas-sovka opened this issue 4 years ago • 3 comments

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.

uzhas-sovka avatar May 12 '20 17:05 uzhas-sovka

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

I lack time to work on this.

mrkkrp avatar May 18 '20 19:05 mrkkrp

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.

uzhas-sovka avatar May 19 '20 03:05 uzhas-sovka

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.

hughjfchen avatar Dec 03 '20 02:12 hughjfchen