Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open-uri is not redirecing http to https

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.

like image 561
leonidus Avatar asked Apr 04 '12 14:04

leonidus


1 Answers

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.

like image 162
ezkl Avatar answered Nov 14 '22 16:11

ezkl