36
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Ruby] open-uriでhttp->httpsのリダイレクトが禁止されている件

Posted at

httpからhttpsへのリダイレクトされるURLをopen-uriで取得しようとするとでエラーが発生する件

> require 'open-uri'
> open('http://github.com')
RuntimeError: redirection forbidden: http://github.com -> https://github.com/

下記のGemで解決
https://github.com/open-uri-redirections/open_uri_redirections

gem 'open_uri_redirections'
> require 'open-uri'
> require 'open_uri_redirections'
> open('http://github.com', :allow_redirections => :safe)
=> #<File:/var/folders/...>
36
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
36
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?