I am using the Savon library which in turn uses HTTPI, but HTTPI considers only HTTP status codes 200..299 as successful. Unfortunately, the SOAP server I am connecting to uses HTTP 302 Found to redirect its clients to other URLs. Is there a way I can configure HTTPI to follow HTTP redirects?
Asked
Active
Viewed 752 times
3 Answers
2
Try using the 'follow_redirect= true' on the request object.
request = HTTPI::Request.new
request.follow_redirect= true
...
Just had this same issue myself.

rolandcedo
- 47
- 8
1
Reading Wasabi code I found this line, which calls this line, which calls this line, so I think you can resolve with a brutal but effective constant redefinition:
HTTPI::Response::SuccessfulResponseCodes = HTTPI::Response::SuccessfulResponseCodes.to_a << 302
You can safely ignore the constant redefinition warning (you can use Kernel.silence_warnings{ ... }
).
Anyway, I suggest you to open an issue to httpi; I think it should be the expected behaviour

mdesantis
- 8,257
- 4
- 31
- 63
-
Close, but it doesn't exactly solve the issue. Now instead of an `Savon::HTTP:Error`, I get an `Savon::SOAP::InvalidResponseError`. – f.ardelian Nov 24 '12 at 21:05
-
:-/ however this is the right way; I think you should start from the line which gives you the error and debug it – mdesantis Nov 25 '12 at 01:55
-
f.ardelian, did you resolve this? I'm having the exact same issue. – tol4trob Sep 04 '14 at 15:46
1
For anyone coming to this as I did from a Google search. Savon 2.11 supports this with a global configuration value on the client:
follow_redirects: true

Dan Barron
- 1,094
- 2
- 15
- 30
-
Thanks! Note that this is not documented, but you can see it in the code here: https://github.com/savonrb/savon/blob/3814eace61050e08aa74aa292a92b88419fc403f/lib/savon/request.rb#L49-L54 – Felipe Zavan Aug 25 '21 at 12:55