Frage

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.

War es hilfreich?

Lösung

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]
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top