문제

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