http 6.0.2 → 6.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93055a5ab4132e9943b15cacd421d7994bf3fb7f1ffdb5eb37865d59c9d353cf
4
- data.tar.gz: 7cb55397feb3a9479d52cf4f4d4de2762ef584daa5d4887f363ae8e0c10f32d6
3
+ metadata.gz: 0ada1c2436fc0b5a9f5eba76d63d7f7846ad7ff2635717693f67ad48c3d9c22b
4
+ data.tar.gz: 016a84342ef4655e6359564b7b2833eb2563f57b4876043e901800187cd2a2e6
5
5
  SHA512:
6
- metadata.gz: 626a25da807e2bc32aa1cb077a7dba2eb20fc0ea0e969e3e9d9c185997baa02072832772d7b6325e7fe00e8a669221032fbad844294d16ae2d62dac1f8b5693b
7
- data.tar.gz: dcc2dc39b1a536d737656654accb528fc613a80862174c9bbb0b709572a7277cf221b1fc38c5f821842fdaf2f129ec37caa3f1754852f9822e2d4408472a3018
6
+ metadata.gz: 03222f88025ec225419f422dc3a2c6823c388354795ebb124630519e79d8ba96955d8e3d956aaba995e4a2c84e3b4932c5773976132967a3128dd6d85d109c87
7
+ data.tar.gz: c9f80325fd4257df0a0dc8e801f9ed5e006562ec8d84dcca009d5359a8c49e5912d6566bc715f65be8c10a3682831a44e3aad7d626640b472b80eccbaedb8211
data/http.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.metadata["rubygems_mfa_required"] = "true"
27
27
 
28
28
  spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
29
- extras = %w[LICENSE.txt README.md sig/http.rbs] << File.basename(__FILE__)
29
+ extras = %w[LICENSE.txt README.md sig/http.rbs sig/llhttp.rbs sig/manifest.yaml] << File.basename(__FILE__)
30
30
 
31
31
  ls.readlines("\x0", chomp: true).select do |f|
32
32
  f.start_with?("lib/") || extras.include?(f)
@@ -254,7 +254,7 @@ module HTTP
254
254
  # @return [void]
255
255
  # @api private
256
256
  def connect_socket(req, options)
257
- @socket = options.timeout_class.new(**options.timeout_options) # steep:ignore
257
+ @socket = options.timeout_class.new(**options.timeout_options)
258
258
  @socket.connect(options.socket_class, req.socket_host, req.socket_port, nodelay: options.nodelay)
259
259
 
260
260
  send_proxy_connect_request(req)
@@ -14,8 +14,8 @@ module HTTP
14
14
  #
15
15
  # Emits two events on every request:
16
16
  #
17
- # * `start_request.http` before the request is made, so you can log the reqest being started
18
- # * `request.http` after the response is recieved, and contains `start`
17
+ # * `start_request.http` before the request is made, so you can log the request being started
18
+ # * `request.http` after the response is received, and contains `start`
19
19
  # and `finish` so the duration of the request can be calculated.
20
20
  #
21
21
  class Instrumentation < Feature
@@ -158,7 +158,7 @@ module HTTP
158
158
  # @return [HTTP::Response::Body]
159
159
  # @api private
160
160
  def logged_body(body)
161
- formatter = (method(:format_binary) unless body.loggable?) # steep:ignore
161
+ formatter = (method(:format_binary) unless body.loggable?)
162
162
  stream = BodyLogger.new(body.instance_variable_get(:@stream), logger, formatter: formatter) # steep:ignore
163
163
  Response::Body.new(stream, encoding: body.encoding)
164
164
  end
@@ -81,7 +81,7 @@ module HTTP
81
81
  # @return [HTTP::URI] the constructed URI
82
82
  # @api private
83
83
  def make_request_uri(uri)
84
- uri = uri.to_s
84
+ uri = neutralize_protocol_relative(uri.to_s)
85
85
 
86
86
  if @options.base_uri? && uri !~ HTTP_OR_HTTPS_RE
87
87
  uri = resolve_against_base(uri)
@@ -101,6 +101,26 @@ module HTTP
101
101
  uri
102
102
  end
103
103
 
104
+ # Neutralize a leading "//" so it resolves as a relative path under base
105
+ #
106
+ # A "//"-prefixed input is a protocol-relative (network-path) reference
107
+ # per RFC 3986 §4.2 / §5.2. On the base_uri branch it would replace the
108
+ # base authority via URI#join; on the persistent branch naive
109
+ # concatenation produces "scheme://persistent//evil/path" which
110
+ # HTTP::URI.parse normalises into scheme://evil/path. Prepending "./"
111
+ # forces the input to resolve as an ordinary relative path under the
112
+ # configured base.
113
+ #
114
+ # @param uri [String] the input URI
115
+ # @return [String] uri unchanged, or "./" + uri when neutralization applies
116
+ # @api private
117
+ def neutralize_protocol_relative(uri)
118
+ return uri unless @options.base_uri? || @options.persistent?
119
+ return uri unless uri.start_with?("//")
120
+
121
+ "./#{uri}"
122
+ end
123
+
104
124
  # Resolve a relative URI against the configured base URI
105
125
  #
106
126
  # Ensures the base URI path has a trailing slash so that relative
data/lib/http/response.rb CHANGED
@@ -337,9 +337,9 @@ module HTTP
337
337
  # @return [HTTP::Request]
338
338
  # @api private
339
339
  def init_request(request, uri)
340
- raise ArgumentError, ":uri is for backwards compatibilty and conflicts with :request" if request && uri
340
+ raise ArgumentError, ":uri is for backwards compatibility and conflicts with :request" if request && uri
341
341
 
342
- # For backwards compatibilty
342
+ # For backwards compatibility
343
343
  if uri
344
344
  HTTP::Request.new(uri: uri, verb: :get)
345
345
  else
@@ -185,12 +185,14 @@ module HTTP
185
185
  # @return [Object] the connected socket
186
186
  # @api private
187
187
  def open_socket(socket_class, host, port, connect_timeout: nil)
188
- if connect_timeout
188
+ return socket_class.open(host, port) unless connect_timeout
189
+
190
+ if native_timeout?(socket_class)
191
+ open_with_timeout(socket_class, host, port, connect_timeout)
192
+ else
189
193
  ::Timeout.timeout(connect_timeout, ConnectTimeoutError) do
190
194
  open_with_timeout(socket_class, host, port, connect_timeout)
191
195
  end
192
- else
193
- socket_class.open(host, port)
194
196
  end
195
197
  rescue IO::TimeoutError
196
198
  raise ConnectTimeoutError, "Connect timed out after #{connect_timeout} seconds"
@@ -171,11 +171,11 @@ module HTTP
171
171
  # @return [Hash] URI components
172
172
  private_class_method def self.parse_with_addressable(uri_string)
173
173
  require_addressable
174
- parsed = Addressable::URI.parse(uri_string) # steep:ignore
174
+ parsed = Addressable::URI.parse(uri_string)
175
175
  { scheme: parsed.scheme, user: parsed.user, password: parsed.password,
176
176
  host: parsed.host, port: parsed.port, path: parsed.path,
177
177
  query: parsed.query, fragment: parsed.fragment }
178
- rescue Addressable::URI::InvalidURIError # steep:ignore
178
+ rescue Addressable::URI::InvalidURIError
179
179
  raise InvalidError, "invalid URI: #{uri_string.inspect}"
180
180
  end
181
181
  end
data/lib/http/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module HTTP
4
4
  # Current library version
5
- VERSION = "6.0.2"
5
+ VERSION = "6.0.4"
6
6
  end
data/sig/http.rbs CHANGED
@@ -818,6 +818,7 @@ module HTTP
818
818
  private
819
819
 
820
820
  def make_request_uri: (String | URI uri) -> URI
821
+ def neutralize_protocol_relative: (String uri) -> String
821
822
  def resolve_against_base: (String uri) -> String
822
823
  def merge_query_params!: (URI uri) -> void
823
824
  def make_request_headers: () -> Headers
data/sig/llhttp.rbs ADDED
@@ -0,0 +1,20 @@
1
+ # Stubs for llhttp / llhttp-ffi, which do not ship their own RBS signatures.
2
+ # Referenced by `HTTP::Response::Parser`, which is part of the public API.
3
+
4
+ module LLHttp
5
+ class Error < StandardError
6
+ end
7
+
8
+ class Parser
9
+ def initialize: (untyped, ?type: Symbol) -> void
10
+ def reset: () -> void
11
+ def <<: (String) -> void
12
+ def status_code: () -> Integer
13
+ def http_major: () -> Integer
14
+ def http_minor: () -> Integer
15
+ end
16
+
17
+ class Delegate
18
+ def initialize: () -> void
19
+ end
20
+ end
data/sig/manifest.yaml ADDED
@@ -0,0 +1,13 @@
1
+ dependencies:
2
+ - name: base64
3
+ - name: digest
4
+ - name: forwardable
5
+ - name: openssl
6
+ - name: pathname
7
+ - name: securerandom
8
+ - name: singleton
9
+ - name: tempfile
10
+ - name: time
11
+ - name: timeout
12
+ - name: uri
13
+ - name: zlib
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.2
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -113,15 +113,17 @@ files:
113
113
  - lib/http/uri/parsing.rb
114
114
  - lib/http/version.rb
115
115
  - sig/http.rbs
116
+ - sig/llhttp.rbs
117
+ - sig/manifest.yaml
116
118
  homepage: https://github.com/httprb/http
117
119
  licenses:
118
120
  - MIT
119
121
  metadata:
120
122
  homepage_uri: https://github.com/httprb/http
121
- source_code_uri: https://github.com/httprb/http/tree/v6.0.2
123
+ source_code_uri: https://github.com/httprb/http/tree/v6.0.4
122
124
  bug_tracker_uri: https://github.com/httprb/http/issues
123
- changelog_uri: https://github.com/httprb/http/blob/v6.0.2/CHANGELOG.md
124
- documentation_uri: https://www.rubydoc.info/gems/http/6.0.2
125
+ changelog_uri: https://github.com/httprb/http/blob/v6.0.4/CHANGELOG.md
126
+ documentation_uri: https://www.rubydoc.info/gems/http/6.0.4
125
127
  rubygems_mfa_required: 'true'
126
128
  rdoc_options: []
127
129
  require_paths:
@@ -137,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
139
  - !ruby/object:Gem::Version
138
140
  version: '0'
139
141
  requirements: []
140
- rubygems_version: 4.0.8
142
+ rubygems_version: 4.0.16
141
143
  specification_version: 4
142
144
  summary: HTTP should be easy
143
145
  test_files: []