Вопрос

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.

Это было полезно?

Решение 2

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 www.yahoo.in

gives you

HTTP/1.1 301 Moved Permanently
Date: Thu, 18 Aug 2016 18:50:05 GMT
...
Cache-Control: max-age=3600, public
Location: http://in.yahoo.com/
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.

Другие советы

You can setup Savon to follow redirect setting up follow_redirects option to true.

Eg: client = Savon.client(wsdl: url, ssl_verify_mode: :none, follow_redirects: true)

Found here: https://github.com/savonrb/savon/issues/243

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top