open-uri 0.2.0 → 0.4.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: fd3851e3c9717fdf0ab94ecd3e40634536479efa3629bf7a68d8b2e9d500f0b5
4
- data.tar.gz: 7b76252eb3160db3d423e1912b1524c2232d9b583b5c626658c5d441a2c81d6f
3
+ metadata.gz: ba843c62b6eeedc0ba41feb9a8539cbbaff5f363cd6f960f7c004153e32b2fbf
4
+ data.tar.gz: 8de6ddfea24c2b7596ae35a4094b3bbf30cae1ed92d142b1a7b0772c9200b456
5
5
  SHA512:
6
- metadata.gz: 5dda9d882265ec914e6c735497b0b5cc3a40dff5935bd960eb6794526828d0228408b3833748d3c52f97fc71851d3d9c747e038befc07b7a1d80d95c583dceb3
7
- data.tar.gz: e86b98303de2d5224144beeb40a554964ef108682efe99e820a29b647f3531194e506eaead760548ae53e074d13448eaa169480331e700bcdbd0f9d724b27c5e
6
+ metadata.gz: a48baeacc9043f013c631ba9f07e4ac9eadff5d04a207dbe87d428d2f0393feb605281f91335ae74bedc2351b238f96858b3cad97e311e36a257026993106c8a
7
+ data.tar.gz: f8f47f6f52bdf4cc73a2d3cf4c898bebe8ccbe8329f53e68b9532b658fdbbe976a5a4d0a6c0d069722b6f260b707a20b2f6ab49aa200db800a2d7e29b0cd4814
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
  #
@@ -31,6 +31,7 @@ module URI
31
31
  super
32
32
  end
33
33
  end
34
+ singleton_class.send(:ruby2_keywords, :open) if respond_to?(:ruby2_keywords, true)
34
35
  end
35
36
 
36
37
  # OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
@@ -89,6 +90,9 @@ end
89
90
  # Author:: Tanaka Akira <akr@m17n.org>
90
91
 
91
92
  module OpenURI
93
+
94
+ VERSION = "0.4.0"
95
+
92
96
  Options = {
93
97
  :proxy => true,
94
98
  :proxy_http_basic_authentication => true,
@@ -99,6 +103,8 @@ module OpenURI
99
103
  :open_timeout => true,
100
104
  :ssl_ca_cert => nil,
101
105
  :ssl_verify_mode => nil,
106
+ :ssl_min_version => nil,
107
+ :ssl_max_version => nil,
102
108
  :ftp_active_mode => false,
103
109
  :redirect => true,
104
110
  :encoding => nil,
@@ -298,6 +304,8 @@ module OpenURI
298
304
  require 'net/https'
299
305
  http.use_ssl = true
300
306
  http.verify_mode = options[:ssl_verify_mode] || OpenSSL::SSL::VERIFY_PEER
307
+ http.min_version = options[:ssl_min_version]
308
+ http.max_version = options[:ssl_max_version]
301
309
  store = OpenSSL::X509::Store.new
302
310
  if options[:ssl_ca_cert]
303
311
  Array(options[:ssl_ca_cert]).each do |cert|
@@ -353,7 +361,8 @@ module OpenURI
353
361
  when Net::HTTPMovedPermanently, # 301
354
362
  Net::HTTPFound, # 302
355
363
  Net::HTTPSeeOther, # 303
356
- Net::HTTPTemporaryRedirect # 307
364
+ Net::HTTPTemporaryRedirect, # 307
365
+ Net::HTTPPermanentRedirect # 308
357
366
  begin
358
367
  loc_uri = URI.parse(resp['location'])
359
368
  rescue URI::InvalidURIError
@@ -410,6 +419,13 @@ module OpenURI
410
419
  end
411
420
  end
412
421
 
422
+ # :stopdoc:
423
+ RE_LWS = /[\r\n\t ]+/n
424
+ RE_TOKEN = %r{[^\x00- ()<>@,;:\\"/\[\]?={}\x7f]+}n
425
+ RE_QUOTED_STRING = %r{"(?:[\r\n\t !#-\[\]-~\x80-\xff]|\\[\x00-\x7f])*"}n
426
+ RE_PARAMETERS = %r{(?:;#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?=#{RE_LWS}?(?:#{RE_TOKEN}|#{RE_QUOTED_STRING})#{RE_LWS}?)*}n
427
+ # :startdoc:
428
+
413
429
  # Mixin for holding meta-information.
414
430
  module Meta
415
431
  def Meta.init(obj, src=nil) # :nodoc:
@@ -487,13 +503,6 @@ module OpenURI
487
503
  end
488
504
  end
489
505
 
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
506
  def content_type_parse # :nodoc:
498
507
  vs = @metas['content-type']
499
508
  # The last (?:;#{RE_LWS}?)? matches extra ";" which violates RFC2045.
@@ -698,6 +707,20 @@ module OpenURI
698
707
  #
699
708
  # :ssl_verify_mode is used to specify openssl verify mode.
700
709
  #
710
+ # [:ssl_min_version]
711
+ # Synopsis:
712
+ # :ssl_min_version=>:TLS1_2
713
+ #
714
+ # :ssl_min_version option specifies the minimum allowed SSL/TLS protocol
715
+ # version. See also OpenSSL::SSL::SSLContext#min_version=.
716
+ #
717
+ # [:ssl_max_version]
718
+ # Synopsis:
719
+ # :ssl_max_version=>:TLS1_2
720
+ #
721
+ # :ssl_max_version option specifies the maximum allowed SSL/TLS protocol
722
+ # version. See also OpenSSL::SSL::SSLContext#max_version=.
723
+ #
701
724
  # [:ftp_active_mode]
702
725
  # Synopsis:
703
726
  # :ftp_active_mode=>bool
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open-uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.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: 2021-10-14 00:00:00.000000000 Z
11
+ date: 2023-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri
@@ -59,16 +59,9 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".github/workflows/test.yml"
63
- - ".gitignore"
64
- - Gemfile
65
62
  - LICENSE.txt
66
63
  - README.md
67
- - Rakefile
68
- - bin/console
69
- - bin/setup
70
64
  - lib/open-uri.rb
71
- - open-uri.gemspec
72
65
  homepage: https://github.com/ruby/open-uri
73
66
  licenses:
74
67
  - Ruby
@@ -91,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
84
  - !ruby/object:Gem::Version
92
85
  version: '0'
93
86
  requirements: []
94
- rubygems_version: 3.2.22
87
+ rubygems_version: 3.5.0.dev
95
88
  signing_key:
96
89
  specification_version: 4
97
90
  summary: An easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
@@ -1,22 +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@v2
15
- - name: Set up Ruby
16
- uses: ruby/setup-ruby@v1
17
- with:
18
- ruby-version: ${{ matrix.ruby }}
19
- - name: Install dependencies
20
- run: bundle install
21
- - name: Run test
22
- 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,17 +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 :sync_tool do
11
- require 'fileutils'
12
- FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
13
- FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
14
- FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
15
- end
16
-
17
- 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,26 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = "open-uri"
3
- spec.version = "0.2.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
-
23
- spec.add_dependency "uri"
24
- spec.add_dependency "stringio"
25
- spec.add_dependency "time"
26
- end