Luigi Luigi - 2 years ago 156
Ruby Question

Can Savon allow redirects? 302 "Error"

Is it possible to make Savon allow redirects? I am currently receiving a 302 HTTP Error, but in reality this should just be a redirect instead of an error.

Answer Source

Savon uses httpi for the connection. httpi itself is a wrapper around curb, em_http, excon, httpclient, net_http and rack.

The file em_http.rb contains the comment that

automatic redirect following

is not supported by httpi. So what I would try to send the call to the redirection target right away if that's possible.

To find the "real" URL you can use a tool like curl, for example:

curl -I

gives you

HTTP/1.1 301 Moved Permanently
Date: Thu, 18 Aug 2016 18:50:05 GMT
Cache-Control: max-age=3600, public
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Age: 0
Connection: keep-alive
Server: ATS

The Location: key shows the address you want to try next. You might get another redirect. You'll have to try until the 200 OK is returned.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download