문제

When I use content = client.get_content(lasturl) I'm getting this error:

/var/lib/gems/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:664:in `default_redirect_uri_callback': redirecting to non-https resource (HTTPClient::BadResponseError)
    from /var/lib/gems/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:962:in `call'
    from /var/lib/gems/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:962:in `follow_redirect'
    from /var/lib/gems/1.9.1/gems/httpclient-2.3.4.1/lib/httpclient.rb:594:in `get_content'
    from he_sender.rb:332:in `<main>'

URL I want to get is https and I already disabled SSL check:

client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE

How I can solve such problem? Thanks.

도움이 되었습니까?

해결책

Redirecting from https to http is bad, and HTTPClient protects you against that.

If you really want to allow for that, and eliminate the exception, you can override redirect_uri_callback:

client.redirect_uri_callback = ->(uri, res) {
  res.header['location'][0]
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top