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