open-uri 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75aa86e8cda2121671eaf25a7566555fdb79f1d572a102d11b9866c31ba72889
4
- data.tar.gz: 8c3061b74a9d593c0e2a848a23590a62562971c954fa127d40d5a60e604f9192
3
+ metadata.gz: fdfb473bed054e3c79c78c0e101bc019b4501a85e4cdf2c4feac15f1e288f427
4
+ data.tar.gz: ee7f6ee4dbc4fde6edb7b30c64ae97230b9862b7f26f3e43a22b42315aa33247
5
5
  SHA512:
6
- metadata.gz: b5c7fd8009abcb73e5ccff0cc7ad53fb35c631f00d28868f5a5b11615483e9c81e1b17ca0dcedc2272c62e9e6b3d34a1c3563afc1553279db43de9a948bcafce
7
- data.tar.gz: 075c510184720259fb6116c428b4bcf33b8eadf3ae3ab7b9b8ac1039fe9dc30a2e3ad93758157bf8496fc3586c26a2f3369cf5ccfd9421e312a2d0fbc984f733
6
+ metadata.gz: 1a448a39f6fb296628117482836b9b2a64dd7a1f465f87b2c224afda3c78defbbd5424c3c123ac784b8e8ec3dfb03ab43b904d55eff7ec255f4c591d16f2537d
7
+ data.tar.gz: d1f741ea9715d11d0cdc2036ba305134cb689e70911fa868d15ca8edcba29e9e802bf12377886896ab4fecaa3140601fdd4b9b6098dc04b4c0db8c0970b6f827
data/lib/open-uri.rb CHANGED
@@ -9,7 +9,7 @@ module URI
9
9
  # If the first argument responds to the 'open' method, 'open' is called on
10
10
  # it with the rest of the arguments.
11
11
  #
12
- # If the first argument is a string that begins with <code>(protocol)://<code>, it is parsed by
12
+ # If the first argument is a string that begins with <code>(protocol)://</code>, it is parsed by
13
13
  # URI.parse. If the parsed object responds to the 'open' method,
14
14
  # 'open' is called on it with the rest of the arguments.
15
15
  #
@@ -99,6 +99,8 @@ module OpenURI
99
99
  :open_timeout => true,
100
100
  :ssl_ca_cert => nil,
101
101
  :ssl_verify_mode => nil,
102
+ :ssl_min_version => nil,
103
+ :ssl_max_version => nil,
102
104
  :ftp_active_mode => false,
103
105
  :redirect => true,
104
106
  :encoding => nil,
@@ -298,6 +300,8 @@ module OpenURI
298
300
  require 'net/https'
299
301
  http.use_ssl = true
300
302
  http.verify_mode = options[:ssl_verify_mode] || OpenSSL::SSL::VERIFY_PEER
303
+ http.min_version = options[:ssl_min_version]
304
+ http.max_version = options[:ssl_max_version]
301
305
  store = OpenSSL::X509::Store.new
302
306
  if options[:ssl_ca_cert]
303
307
  Array(options[:ssl_ca_cert]).each do |cert|
@@ -353,7 +357,8 @@ module OpenURI
353
357
  when Net::HTTPMovedPermanently, # 301
354
358
  Net::HTTPFound, # 302
355
359
  Net::HTTPSeeOther, # 303
356
- Net::HTTPTemporaryRedirect # 307
360
+ Net::HTTPTemporaryRedirect, # 307
361
+ Net::HTTPPermanentRedirect # 308
357
362
  begin
358
363
  loc_uri = URI.parse(resp['location'])
359
364
  rescue URI::InvalidURIError
@@ -410,6 +415,13 @@ module OpenURI
410
415
  end
411
416
  end
412
417
 
418
+ # :stopdoc:
419
+ RE_LWS = /[\r\n\t ]+/n
420
+ RE_TOKEN = %r{[^\x00- ()<>@,;:\\"/\[\]?={}\x7f]+}n
421
+ RE_QUOTED_STRING = %r{"(?:[\r\n\t !#-\[\]-~\x80-\xff]|\\[\x00-\x7f])*"}n
422
+ RE_PARAMETERS = %r{(?:;#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?=#{RE_LWS}?(?:#{RE_TOKEN}|#{RE_QUOTED_STRING})#{RE_LWS}?)*}n
423
+ # :startdoc:
424
+
413
425
  # Mixin for holding meta-information.
414
426
  module Meta
415
427
  def Meta.init(obj, src=nil) # :nodoc:
@@ -487,13 +499,6 @@ module OpenURI
487
499
  end
488
500
  end
489
501
 
490
- # :stopdoc:
491
- RE_LWS = /[\r\n\t ]+/n
492
- RE_TOKEN = %r{[^\x00- ()<>@,;:\\"/\[\]?={}\x7f]+}n
493
- RE_QUOTED_STRING = %r{"(?:[\r\n\t !#-\[\]-~\x80-\xff]|\\[\x00-\x7f])*"}n
494
- RE_PARAMETERS = %r{(?:;#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?=#{RE_LWS}?(?:#{RE_TOKEN}|#{RE_QUOTED_STRING})#{RE_LWS}?)*}n
495
- # :startdoc:
496
-
497
502
  def content_type_parse # :nodoc:
498
503
  vs = @metas['content-type']
499
504
  # The last (?:;#{RE_LWS}?)? matches extra ";" which violates RFC2045.
@@ -698,6 +703,20 @@ module OpenURI
698
703
  #
699
704
  # :ssl_verify_mode is used to specify openssl verify mode.
700
705
  #
706
+ # [:ssl_min_version]
707
+ # Synopsis:
708
+ # :ssl_min_version=>:TLS1_2
709
+ #
710
+ # :ssl_min_version option specifies the minimum allowed SSL/TLS protocol
711
+ # version. See also OpenSSL::SSL::SSLContext#min_version=.
712
+ #
713
+ # [:ssl_max_version]
714
+ # Synopsis:
715
+ # :ssl_max_version=>:TLS1_2
716
+ #
717
+ # :ssl_max_version option specifies the maximum allowed SSL/TLS protocol
718
+ # version. See also OpenSSL::SSL::SSLContext#max_version=.
719
+ #
701
720
  # [:ftp_active_mode]
702
721
  # Synopsis:
703
722
  # :ftp_active_mode=>bool
@@ -750,7 +769,12 @@ module URI
750
769
  OpenURI.open_http(buf, self, proxy, options)
751
770
  return
752
771
  end
753
- require 'net/ftp'
772
+
773
+ begin
774
+ require 'net/ftp'
775
+ rescue LoadError
776
+ abort "net/ftp is not found. You may need to `gem install net-ftp` to install net/ftp."
777
+ end
754
778
 
755
779
  path = self.path
756
780
  path = path.sub(%r{\A/}, '%2F') # re-encode the beginning slash because uri library decodes it.
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open-uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanaka Akira
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: uri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: stringio
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: time
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description: An easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
14
56
  email:
15
57
  - akr@fsij.org
@@ -17,16 +59,9 @@ executables: []
17
59
  extensions: []
18
60
  extra_rdoc_files: []
19
61
  files:
20
- - ".github/workflows/test.yml"
21
- - ".gitignore"
22
- - Gemfile
23
62
  - LICENSE.txt
24
63
  - README.md
25
- - Rakefile
26
- - bin/console
27
- - bin/setup
28
64
  - lib/open-uri.rb
29
- - open-uri.gemspec
30
65
  homepage: https://github.com/ruby/open-uri
31
66
  licenses:
32
67
  - Ruby
@@ -49,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
84
  - !ruby/object:Gem::Version
50
85
  version: '0'
51
86
  requirements: []
52
- rubygems_version: 3.2.0.rc.1
87
+ rubygems_version: 3.4.0.dev
53
88
  signing_key:
54
89
  specification_version: 4
55
90
  summary: An easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
@@ -1,24 +0,0 @@
1
- name: test
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
- strategy:
9
- matrix:
10
- ruby: [ 2.7, 2.6, 2.5, head ]
11
- os: [ ubuntu-latest, macos-latest ]
12
- runs-on: ${{ matrix.os }}
13
- steps:
14
- - uses: actions/checkout@master
15
- - name: Set up Ruby
16
- uses: ruby/setup-ruby@v1
17
- with:
18
- ruby-version: ${{ matrix.ruby }}
19
- - name: Install dependencies
20
- run: |
21
- gem install bundler --no-document
22
- bundle install
23
- - name: Run test
24
- run: rake test
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "rake"
4
- gem "test-unit"
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test/lib"
6
- t.ruby_opts << "-rhelper"
7
- t.test_files = FileList["test/**/test_*.rb"]
8
- end
9
-
10
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "open/uri"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/open-uri.gemspec DELETED
@@ -1,22 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = "open-uri"
3
- spec.version = "0.1.0"
4
- spec.authors = ["Tanaka Akira"]
5
- spec.email = ["akr@fsij.org"]
6
-
7
- spec.summary = %q{An easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.}
8
- spec.description = %q{An easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.}
9
- spec.homepage = "https://github.com/ruby/open-uri"
10
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
11
- spec.licenses = ["Ruby", "BSD-2-Clause"]
12
-
13
- spec.metadata["homepage_uri"] = spec.homepage
14
- spec.metadata["source_code_uri"] = spec.homepage
15
-
16
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- end
19
- spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
- end