net-http 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.github/workflows/test.yml +3 -5
 - data/Gemfile +1 -0
 - data/Gemfile.lock +11 -1
 - data/README.md +1 -1
 - data/Rakefile +1 -1
 - data/lib/net/http/generic_request.rb +2 -4
 - data/lib/net/http.rb +24 -15
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3218ca14e4d201668faf051c7e2920054e7e02410ade361a466ce614a662d69f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0331ab0f1b2d9160faa5842f892780d9d933bdbc5102608a5cfc51b2d116f043
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: '02074786b78a941fedbd736b6fcf987f31f3c5b33a3215bc4f7017bed37188cb33cdfe1d69c6a35f81377f91858772cb020c14286f3413c48b341853062574ff'
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e5612a685ba130029da39e40085b2b15be9e4ce65093846c51b1d96ea924860c1b7224e0cd05eba188bf2e648a07e8daa3fe0d227f3a7c8aa3e5ea18307f23f0
         
     | 
    
        data/.github/workflows/test.yml
    CHANGED
    
    | 
         @@ -7,18 +7,16 @@ jobs: 
     | 
|
| 
       7 
7 
     | 
    
         
             
                name: build (${{ matrix.ruby }} / ${{ matrix.os }})
         
     | 
| 
       8 
8 
     | 
    
         
             
                strategy:
         
     | 
| 
       9 
9 
     | 
    
         
             
                  matrix:
         
     | 
| 
       10 
     | 
    
         
            -
                    ruby: [ 2.7, 2.6, head ]
         
     | 
| 
      
 10 
     | 
    
         
            +
                    ruby: [ '3.0', 2.7, 2.6, head ]
         
     | 
| 
       11 
11 
     | 
    
         
             
                    os: [ ubuntu-latest, macos-latest ]
         
     | 
| 
       12 
12 
     | 
    
         
             
                runs-on: ${{ matrix.os }}
         
     | 
| 
       13 
13 
     | 
    
         
             
                steps:
         
     | 
| 
       14 
     | 
    
         
            -
                - uses: actions/checkout@ 
     | 
| 
      
 14 
     | 
    
         
            +
                - uses: actions/checkout@v2
         
     | 
| 
       15 
15 
     | 
    
         
             
                - name: Set up Ruby
         
     | 
| 
       16 
16 
     | 
    
         
             
                  uses: ruby/setup-ruby@v1
         
     | 
| 
       17 
17 
     | 
    
         
             
                  with:
         
     | 
| 
       18 
18 
     | 
    
         
             
                    ruby-version: ${{ matrix.ruby }}
         
     | 
| 
       19 
19 
     | 
    
         
             
                - name: Install dependencies
         
     | 
| 
       20 
     | 
    
         
            -
                  run:  
     | 
| 
       21 
     | 
    
         
            -
                    gem install bundler --no-document
         
     | 
| 
       22 
     | 
    
         
            -
                    bundle install
         
     | 
| 
      
 20 
     | 
    
         
            +
                  run: bundle install
         
     | 
| 
       23 
21 
     | 
    
         
             
                - name: Run test
         
     | 
| 
       24 
22 
     | 
    
         
             
                  run: rake test
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,15 +1,24 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                net-http (0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
                net-http (0.1.1)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  net-protocol
         
     | 
| 
      
 6 
     | 
    
         
            +
                  uri
         
     | 
| 
       5 
7 
     | 
    
         | 
| 
       6 
8 
     | 
    
         
             
            GEM
         
     | 
| 
       7 
9 
     | 
    
         
             
              remote: https://rubygems.org/
         
     | 
| 
       8 
10 
     | 
    
         
             
              specs:
         
     | 
| 
      
 11 
     | 
    
         
            +
                io-wait (0.1.0)
         
     | 
| 
      
 12 
     | 
    
         
            +
                net-protocol (0.1.0)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  io-wait
         
     | 
| 
      
 14 
     | 
    
         
            +
                  timeout
         
     | 
| 
       9 
15 
     | 
    
         
             
                power_assert (1.1.5)
         
     | 
| 
       10 
16 
     | 
    
         
             
                rake (13.0.1)
         
     | 
| 
       11 
17 
     | 
    
         
             
                test-unit (3.3.5)
         
     | 
| 
       12 
18 
     | 
    
         
             
                  power_assert
         
     | 
| 
      
 19 
     | 
    
         
            +
                timeout (0.1.1)
         
     | 
| 
      
 20 
     | 
    
         
            +
                uri (0.10.1)
         
     | 
| 
      
 21 
     | 
    
         
            +
                webrick (1.7.0)
         
     | 
| 
       13 
22 
     | 
    
         | 
| 
       14 
23 
     | 
    
         
             
            PLATFORMS
         
     | 
| 
       15 
24 
     | 
    
         
             
              ruby
         
     | 
| 
         @@ -18,6 +27,7 @@ DEPENDENCIES 
     | 
|
| 
       18 
27 
     | 
    
         
             
              net-http!
         
     | 
| 
       19 
28 
     | 
    
         
             
              rake
         
     | 
| 
       20 
29 
     | 
    
         
             
              test-unit
         
     | 
| 
      
 30 
     | 
    
         
            +
              webrick
         
     | 
| 
       21 
31 
     | 
    
         | 
| 
       22 
32 
     | 
    
         
             
            BUNDLED WITH
         
     | 
| 
       23 
33 
     | 
    
         
             
               2.1.4
         
     | 
    
        data/README.md
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -9,7 +9,7 @@ end 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            task :sync_tool do
         
     | 
| 
       11 
11 
     | 
    
         
             
              require 'fileutils'
         
     | 
| 
       12 
     | 
    
         
            -
              FileUtils.cp "../ruby/tool/lib/ 
     | 
| 
      
 12 
     | 
    
         
            +
              FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
         
     | 
| 
       13 
13 
     | 
    
         
             
              FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
         
     | 
| 
       14 
14 
     | 
    
         
             
              FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
         
     | 
| 
       15 
15 
     | 
    
         
             
            end
         
     | 
| 
         @@ -143,7 +143,7 @@ class Net::HTTPGenericRequest 
     | 
|
| 
       143 
143 
     | 
    
         
             
                end
         
     | 
| 
       144 
144 
     | 
    
         | 
| 
       145 
145 
     | 
    
         
             
                if host = self['host']
         
     | 
| 
       146 
     | 
    
         
            -
                  host.sub!(/:.*/ 
     | 
| 
      
 146 
     | 
    
         
            +
                  host.sub!(/:.*/m, ''.freeze)
         
     | 
| 
       147 
147 
     | 
    
         
             
                elsif host = @uri.host
         
     | 
| 
       148 
148 
     | 
    
         
             
                else
         
     | 
| 
       149 
149 
     | 
    
         
             
                 host = addr
         
     | 
| 
         @@ -202,9 +202,7 @@ class Net::HTTPGenericRequest 
     | 
|
| 
       202 
202 
     | 
    
         
             
                  IO.copy_stream(f, chunker)
         
     | 
| 
       203 
203 
     | 
    
         
             
                  chunker.finish
         
     | 
| 
       204 
204 
     | 
    
         
             
                else
         
     | 
| 
       205 
     | 
    
         
            -
                   
     | 
| 
       206 
     | 
    
         
            -
                  # If sock.io is an SSLSocket, copy_stream will hit SSL_write()
         
     | 
| 
       207 
     | 
    
         
            -
                  IO.copy_stream(f, sock.io)
         
     | 
| 
      
 205 
     | 
    
         
            +
                  IO.copy_stream(f, sock)
         
     | 
| 
       208 
206 
     | 
    
         
             
                end
         
     | 
| 
       209 
207 
     | 
    
         
             
              end
         
     | 
| 
       210 
208 
     | 
    
         | 
    
        data/lib/net/http.rb
    CHANGED
    
    | 
         @@ -388,12 +388,11 @@ module Net   #:nodoc: 
     | 
|
| 
       388 
388 
     | 
    
         
             
              class HTTP < Protocol
         
     | 
| 
       389 
389 
     | 
    
         | 
| 
       390 
390 
     | 
    
         
             
                # :stopdoc:
         
     | 
| 
       391 
     | 
    
         
            -
                VERSION = "0. 
     | 
| 
      
 391 
     | 
    
         
            +
                VERSION = "0.2.0"
         
     | 
| 
       392 
392 
     | 
    
         
             
                Revision = %q$Revision$.split[1]
         
     | 
| 
       393 
393 
     | 
    
         
             
                HTTPVersion = '1.1'
         
     | 
| 
       394 
394 
     | 
    
         
             
                begin
         
     | 
| 
       395 
395 
     | 
    
         
             
                  require 'zlib'
         
     | 
| 
       396 
     | 
    
         
            -
                  require 'stringio'  #for our purposes (unpacking gzip) lump these together
         
     | 
| 
       397 
396 
     | 
    
         
             
                  HAVE_ZLIB=true
         
     | 
| 
       398 
397 
     | 
    
         
             
                rescue LoadError
         
     | 
| 
       399 
398 
     | 
    
         
             
                  HAVE_ZLIB=false
         
     | 
| 
         @@ -524,14 +523,13 @@ module Net   #:nodoc: 
     | 
|
| 
       524 
523 
     | 
    
         
             
                #
         
     | 
| 
       525 
524 
     | 
    
         
             
                #   { "cmd" => "search", "q" => "ruby", "max" => "50" }
         
     | 
| 
       526 
525 
     | 
    
         
             
                #
         
     | 
| 
       527 
     | 
    
         
            -
                # This method also does Basic Authentication  
     | 
| 
      
 526 
     | 
    
         
            +
                # This method also does Basic Authentication if and only if +url+.user exists.
         
     | 
| 
       528 
527 
     | 
    
         
             
                # But userinfo for authentication is deprecated (RFC3986).
         
     | 
| 
       529 
528 
     | 
    
         
             
                # So this feature will be removed.
         
     | 
| 
       530 
529 
     | 
    
         
             
                #
         
     | 
| 
       531 
530 
     | 
    
         
             
                # Example:
         
     | 
| 
       532 
531 
     | 
    
         
             
                #
         
     | 
| 
       533 
532 
     | 
    
         
             
                #   require 'net/http'
         
     | 
| 
       534 
     | 
    
         
            -
                #   require 'uri'
         
     | 
| 
       535 
533 
     | 
    
         
             
                #
         
     | 
| 
       536 
534 
     | 
    
         
             
                #   Net::HTTP.post_form URI('http://www.example.com/search.cgi'),
         
     | 
| 
       537 
535 
     | 
    
         
             
                #                       { "q" => "ruby", "max" => "50" }
         
     | 
| 
         @@ -973,6 +971,12 @@ module Net   #:nodoc: 
     | 
|
| 
       973 
971 
     | 
    
         
             
                private :do_start
         
     | 
| 
       974 
972 
     | 
    
         | 
| 
       975 
973 
     | 
    
         
             
                def connect
         
     | 
| 
      
 974 
     | 
    
         
            +
                  if use_ssl?
         
     | 
| 
      
 975 
     | 
    
         
            +
                    # reference early to load OpenSSL before connecting,
         
     | 
| 
      
 976 
     | 
    
         
            +
                    # as OpenSSL may take time to load.
         
     | 
| 
      
 977 
     | 
    
         
            +
                    @ssl_context = OpenSSL::SSL::SSLContext.new
         
     | 
| 
      
 978 
     | 
    
         
            +
                  end
         
     | 
| 
      
 979 
     | 
    
         
            +
             
     | 
| 
       976 
980 
     | 
    
         
             
                  if proxy? then
         
     | 
| 
       977 
981 
     | 
    
         
             
                    conn_addr = proxy_address
         
     | 
| 
       978 
982 
     | 
    
         
             
                    conn_port = proxy_port
         
     | 
| 
         @@ -982,14 +986,13 @@ module Net   #:nodoc: 
     | 
|
| 
       982 
986 
     | 
    
         
             
                  end
         
     | 
| 
       983 
987 
     | 
    
         | 
| 
       984 
988 
     | 
    
         
             
                  D "opening connection to #{conn_addr}:#{conn_port}..."
         
     | 
| 
       985 
     | 
    
         
            -
                   
     | 
| 
       986 
     | 
    
         
            -
                     
     | 
| 
       987 
     | 
    
         
            -
             
     | 
| 
       988 
     | 
    
         
            -
                     
     | 
| 
       989 
     | 
    
         
            -
             
     | 
| 
       990 
     | 
    
         
            -
             
     | 
| 
       991 
     | 
    
         
            -
             
     | 
| 
       992 
     | 
    
         
            -
                  }
         
     | 
| 
      
 989 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 990 
     | 
    
         
            +
                    s = Socket.tcp conn_addr, conn_port, @local_host, @local_port, connect_timeout: @open_timeout
         
     | 
| 
      
 991 
     | 
    
         
            +
                  rescue => e
         
     | 
| 
      
 992 
     | 
    
         
            +
                    e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) #for compatibility with previous versions
         
     | 
| 
      
 993 
     | 
    
         
            +
                    raise e, "Failed to open TCP connection to " +
         
     | 
| 
      
 994 
     | 
    
         
            +
                      "#{conn_addr}:#{conn_port} (#{e.message})"
         
     | 
| 
      
 995 
     | 
    
         
            +
                  end
         
     | 
| 
       993 
996 
     | 
    
         
             
                  s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
         
     | 
| 
       994 
997 
     | 
    
         
             
                  D "opened"
         
     | 
| 
       995 
998 
     | 
    
         
             
                  if use_ssl?
         
     | 
| 
         @@ -1020,7 +1023,6 @@ module Net   #:nodoc: 
     | 
|
| 
       1020 
1023 
     | 
    
         
             
                        end
         
     | 
| 
       1021 
1024 
     | 
    
         
             
                      end
         
     | 
| 
       1022 
1025 
     | 
    
         
             
                    end
         
     | 
| 
       1023 
     | 
    
         
            -
                    @ssl_context = OpenSSL::SSL::SSLContext.new
         
     | 
| 
       1024 
1026 
     | 
    
         
             
                    @ssl_context.set_params(ssl_parameters)
         
     | 
| 
       1025 
1027 
     | 
    
         
             
                    @ssl_context.session_cache_mode =
         
     | 
| 
       1026 
1028 
     | 
    
         
             
                      OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |
         
     | 
| 
         @@ -1180,7 +1182,8 @@ module Net   #:nodoc: 
     | 
|
| 
       1180 
1182 
     | 
    
         
             
                # The username of the proxy server, if one is configured.
         
     | 
| 
       1181 
1183 
     | 
    
         
             
                def proxy_user
         
     | 
| 
       1182 
1184 
     | 
    
         
             
                  if ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE && @proxy_from_env
         
     | 
| 
       1183 
     | 
    
         
            -
                    proxy_uri&.user
         
     | 
| 
      
 1185 
     | 
    
         
            +
                    user = proxy_uri&.user
         
     | 
| 
      
 1186 
     | 
    
         
            +
                    unescape(user) if user
         
     | 
| 
       1184 
1187 
     | 
    
         
             
                  else
         
     | 
| 
       1185 
1188 
     | 
    
         
             
                    @proxy_user
         
     | 
| 
       1186 
1189 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1189,7 +1192,8 @@ module Net   #:nodoc: 
     | 
|
| 
       1189 
1192 
     | 
    
         
             
                # The password of the proxy server, if one is configured.
         
     | 
| 
       1190 
1193 
     | 
    
         
             
                def proxy_pass
         
     | 
| 
       1191 
1194 
     | 
    
         
             
                  if ENVIRONMENT_VARIABLE_IS_MULTIUSER_SAFE && @proxy_from_env
         
     | 
| 
       1192 
     | 
    
         
            -
                    proxy_uri&.password
         
     | 
| 
      
 1195 
     | 
    
         
            +
                    pass = proxy_uri&.password
         
     | 
| 
      
 1196 
     | 
    
         
            +
                    unescape(pass) if pass
         
     | 
| 
       1193 
1197 
     | 
    
         
             
                  else
         
     | 
| 
       1194 
1198 
     | 
    
         
             
                    @proxy_pass
         
     | 
| 
       1195 
1199 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1200,6 +1204,11 @@ module Net   #:nodoc: 
     | 
|
| 
       1200 
1204 
     | 
    
         | 
| 
       1201 
1205 
     | 
    
         
             
                private
         
     | 
| 
       1202 
1206 
     | 
    
         | 
| 
      
 1207 
     | 
    
         
            +
                def unescape(value)
         
     | 
| 
      
 1208 
     | 
    
         
            +
                  require 'cgi/util'
         
     | 
| 
      
 1209 
     | 
    
         
            +
                  CGI.unescape(value)
         
     | 
| 
      
 1210 
     | 
    
         
            +
                end
         
     | 
| 
      
 1211 
     | 
    
         
            +
             
     | 
| 
       1203 
1212 
     | 
    
         
             
                # without proxy, obsolete
         
     | 
| 
       1204 
1213 
     | 
    
         | 
| 
       1205 
1214 
     | 
    
         
             
                def conn_address # :nodoc:
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: net-http
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - NARUSE, Yui
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-10-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: net-protocol
         
     | 
| 
         @@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       89 
89 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       90 
90 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       91 
91 
     | 
    
         
             
            requirements: []
         
     | 
| 
       92 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 92 
     | 
    
         
            +
            rubygems_version: 3.3.0.dev
         
     | 
| 
       93 
93 
     | 
    
         
             
            signing_key:
         
     | 
| 
       94 
94 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       95 
95 
     | 
    
         
             
            summary: HTTP client api for Ruby.
         
     |