open-uri不会将http重定向到https [英] open-uri is not redirecing http to https

查看:158
本文介绍了open-uri不会将http重定向到https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Hpricot和OpenURI解析网页并从中提取网址。



当我得到类似http:rapidshare.com的链接时,它不是重定向到https。
这是我得到的错误:

  /home/leonidus/.rvm/rubies/ruby-1.9.3 -p125 / lib / ruby​​ / 1.9.1 / open-uri.rb:216:在
中`open_loop':重定向被禁止:http:................. =>
https:.........................


我尝试使用异常处理程序 OPENURI :: HTTPREDIRECT 但是我再次遇到同样的错误。我尝试了所有的博客,但它在那里也没有解决。 这个Ruby bug报告,用于讨论您遇到此问题的原因。请参阅此要点,以获得OpenURI的猴子补丁以允许不安全的重定向。


I am using Hpricot and OpenURI to parse webpages and extract URLs from them.

When I get a link like "http:rapidshare.com", it is not redirecting to https. This is the error I got:

/home/leonidus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:216:in 
`open_loop': redirection forbidden: http:.................=>     
https:.........................
.
.

I tried to use the exception handler OPENURI::HTTPREDIRECT but then again I am getting the same error. I tried all the blogs but it is not resolved there also.

解决方案

See this Ruby bug report for a discussion of why you're experiencing this issue. See this gist for a monkey patch to OpenURI to allow "unsafe" redirects.

这篇关于open-uri不会将http重定向到https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆