Can Ruby HTTPI library be configured for subsequent redirects?

I use the Savon library, which in turn uses HTTPI , but HTTPI only considers HTTP 200..299 status codes to be successful. Unfortunately, the SOAP server I'm connecting to uses HTTP 302 Found to redirect its clients to other URLs. Is there a way to configure HTTPI to track HTTP redirects?

+4
source share
3 answers

Reading Wasabi Code I found this line that calls this line , which calls this line , so I think you can solve it with a brutal but effective persistent override:

HTTPI::Response::SuccessfulResponseCodes = HTTPI::Response::SuccessfulResponseCodes.to_a << 302 

You can safely ignore the warning of constant redefinition (you can use Kernel.silence_warnings{ ... } ).

In any case, I suggest you open the httpi question; I think this should be the expected behavior.

+1
source

Try using 'follow_redirect = true' in the request object.

  request = HTTPI::Request.new request.follow_redirect= true ... 

I just had the same problem.

+2
source

For those who approach this, as in Google search. Savon 2.11 supports this with a global configuration value on the client:

 follow_redirects: true 
0
source

Source: https://habr.com/ru/post/1448123/


All Articles