Skip to content

Comments

use https and URI.open#8

Open
artisr wants to merge 3 commits intominvs1:masterfrom
artisr:master
Open

use https and URI.open#8
artisr wants to merge 3 commits intominvs1:masterfrom
artisr:master

Conversation

@artisr
Copy link

@artisr artisr commented Apr 18, 2021

Hi,

thanks for the gem!

Lets download public key via https :)

calling URI.open via Kernel#open was deprecated some time ago
and it doesn't work on ruby 3 for me so I changed it call URI.open directly

here was my output, this pr fixes it.

artis@Artiss-MacBook-Pro paysera % irb          
3.0.0 :001'> require 'open-uri'
 => true 
3.0.0 :002 > open('https://www.paysera.com/download/public.key')
Traceback (most recent call last):
        6: from /Users/artis/.rvm/rubies/ruby-3.0.0/bin/irb:23:in `<main>'
        5: from /Users/artis/.rvm/rubies/ruby-3.0.0/bin/irb:23:in `load'
        4: from /Users/artis/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
        3: from (irb):2:in `<main>'
        2: from (irb):2:in `open'
        1: from (irb):2:in `initialize'
Errno::ENOENT (No such file or directory @ rb_sysopen - https://www.paysera.com/download/public.key)
3.0.0 :003 > exit
artis@Artiss-MacBook-Pro paysera % rvm use 2.7.0
Using /Users/artis/.rvm/gems/ruby-2.7.0
artis@Artiss-MacBook-Pro paysera % irb
2.7.0 :001 > require 'open-uri'
 => true 
2.7.0 :002 > open('https://www.paysera.com/download/public.key')
(irb):2: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open
 => #<StringIO:0x00007fcc79170de8 @base_uri=#<URI::HTTPS https://www.paysera.com/download/public.key>, @meta={"date"=>"Sun, 18 Apr 2021 09:04:52 GMT", "content-type"=>"application/octet-stream", "content-length"=>"1461", "connection"=>"keep-alive", "set-cookie"=>"__cfduid=dee2435db8fa3333dfe0425a2fd21a1651618736692; expires=Tue, 18-May-21 09:04:52 GMT; path=/; domain=.paysera.com; HttpOnly; SameSite=Lax", "last-modified"=>"Fri, 16 Apr 2021 13:42:53 GMT", "etag"=>"\"6079945d-5b5\"", "x-backend"=>"mokejimai-web-hw4", "accept-ranges"=>"bytes", "cache-control"=>"public, max-age=43200", "cf-cache-status"=>"DYNAMIC", "cf-request-id"=>"0985d2d5290000ffd497a57000000001", "expect-ct"=>"max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"", "x-content-type-options"=>"nosniff", "server"=>"cloudflare", "cf-ray"=>"641cba6849e3ffd4-WAW"}, @metas={"date"=>["Sun, 18 Apr 2021 09:04:52 GMT"], "content-type"=>["application/octet-stream"], "content-length"=>["1461"], "connection"=>["keep-alive"], "set-cookie"=>["__cfduid=dee2435db8fa3333dfe0425a2fd21a1651618736692; expires=Tue, 18-May-21 09:04:52 GMT; path=/; domain=.paysera.com; HttpOnly; SameSite=Lax"], "last-modified"=>["Fri, 16 Apr 2021 13:42:53 GMT"], "etag"=>["\"6079945d-5b5\""], "x-backend"=>["mokejimai-web-hw4"], "accept-ranges"=>["bytes"], "cache-control"=>["public, max-age=43200"], "cf-cache-status"=>["DYNAMIC"], "cf-request-id"=>["0985d2d5290000ffd497a57000000001"], "expect-ct"=>["max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""], "x-content-type-options"=>["nosniff"], "server"=>["cloudflare"], "cf-ray"=>["641cba6849e3ffd4-WAW"]}, @status=["200", "OK"]> 
2.7.0 :003 > 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant