Vra

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.

Was dit nuttig?

Oplossing

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]
}
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top