async-http 0.71.0 → 0.73.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: 86bc918af980c024aca7370544452805f98f6b207eb6bc9e86f605ba21a7a612
4
- data.tar.gz: 595e2f1ce10a7cf2864992380e27398602f7e7ff956f73fd2e733f50bd02ca31
3
+ metadata.gz: 01cf4d909911a28f4f386982504e5865d9053210af1cb121a4acc8e0812a63bd
4
+ data.tar.gz: 20b913990be812792c72f5e68649ee8084310112287e316c438c6a220cee9982
5
5
  SHA512:
6
- metadata.gz: 0fa98ca844d1f7b956128b17b4587756df1b8d164effb82b6704fbc61f50106095429fd7cb6596f6658ebe050c605b819fcbf3121ebc9939f739c1435f6eaac1
7
- data.tar.gz: 9489e703af232522f9db1f8d931a2a31c810538b5592cdd0868af102ee3585161a7f912a14b62dcfccd412d1cd06e26e03472bd033c5f4183f4974b3e8d7f6d4
6
+ metadata.gz: 6b1eefc4c6f0d1a631c1b6f0365ae36a7fe4067e1b372f334473b99f379f0755d29d53a5a04183f5eef46a9c0cf6504a2a56b7c5741757700b44d5c2283fb129
7
+ data.tar.gz: 1ed32dc7b17b30ddd2d842e688e89df28a0cc51a0610398ea567191c6158c5adde2ebdd337035450fca499b0c312e2d9b3bed616f9cf1058c1d136bbdd10acd4
checksums.yaml.gz.sig CHANGED
Binary file
@@ -165,6 +165,10 @@ module Async
165
165
  end
166
166
 
167
167
  super.tap do |response|
168
+ if version = response&.version
169
+ span['http.version'] = version
170
+ end
171
+
168
172
  if status = response&.status
169
173
  span['http.status_code'] = status
170
174
  end
@@ -81,17 +81,7 @@ module Async
81
81
  # We don't want to follow redirects for HEAD requests:
82
82
  return super if request.head?
83
83
 
84
- if body = request.body
85
- if body.respond_to?(:rewind)
86
- # The request body was already rewindable, so use it as is:
87
- body = request.body
88
- else
89
- # The request body was not rewindable, and we might need to resubmit it if we get a response status of 307 or 308, so make it rewindable:
90
- body = ::Protocol::HTTP::Body::Rewindable.new(body)
91
- request.body = body
92
- end
93
- end
94
-
84
+ body = ::Protocol::HTTP::Body::Rewindable.wrap(request)
95
85
  hops = 0
96
86
 
97
87
  while hops <= @maximum_hops
@@ -24,7 +24,7 @@ module Async
24
24
  # HTTP/1 requests with an upgrade header (which can contain zero or more values) are extracted into the protocol field of the request, and we expect a response to select one of those protocols with a status code of 101 Switching Protocols.
25
25
  protocol = headers.delete('upgrade')
26
26
 
27
- super(nil, authority, method, path, version, headers, body, protocol)
27
+ super(nil, authority, method, path, version, headers, body, protocol, self.public_method(:write_interim_response))
28
28
  end
29
29
 
30
30
  def connection
@@ -39,8 +39,8 @@ module Async
39
39
  @connection.hijack!
40
40
  end
41
41
 
42
- def write_interim_response(response)
43
- @connection.write_interim_response(response.version, response.status, response.headers)
42
+ def write_interim_response(status, headers = nil)
43
+ @connection.write_interim_response(@version, status, headers)
44
44
  end
45
45
  end
46
46
  end
@@ -17,6 +17,8 @@ module Async
17
17
 
18
18
  if response.final?
19
19
  return response
20
+ else
21
+ request.send_interim_response(response.status, response.headers)
20
22
  end
21
23
  end
22
24
  end
@@ -23,6 +23,8 @@ module Async
23
23
  attr :request
24
24
 
25
25
  def receive_initial_headers(headers, end_stream)
26
+ @headers = ::Protocol::HTTP::Headers.new
27
+
26
28
  headers.each do |key, value|
27
29
  if key == SCHEME
28
30
  raise ::Protocol::HTTP2::HeaderError, "Request scheme already specified!" if @request.scheme
@@ -85,7 +87,7 @@ module Async
85
87
  end
86
88
 
87
89
  def initialize(stream)
88
- super(nil, nil, nil, nil, VERSION, nil)
90
+ super(nil, nil, nil, nil, VERSION, nil, nil, nil, self.public_method(:write_interim_response))
89
91
 
90
92
  @stream = stream
91
93
  end
@@ -117,10 +119,6 @@ module Async
117
119
  [STATUS, response.status],
118
120
  ]
119
121
 
120
- if protocol = response.protocol
121
- protocol_headers << [PROTOCOL, protocol]
122
- end
123
-
124
122
  if length = response.body&.length
125
123
  protocol_headers << [CONTENT_LENGTH, length]
126
124
  end
@@ -142,14 +140,16 @@ module Async
142
140
  end
143
141
  end
144
142
 
145
- def write_interim_response(response)
146
- protocol_headers = [
147
- [STATUS, response.status]
143
+ def write_interim_response(status, headers = nil)
144
+ interim_response_headers = [
145
+ [STATUS, status]
148
146
  ]
149
147
 
150
- headers = ::Protocol::HTTP::Headers::Merged.new(protocol_headers, response.headers)
148
+ if headers
149
+ interim_response_headers = ::Protocol::HTTP::Headers::Merged.new(interim_response_headers, headers)
150
+ end
151
151
 
152
- @stream.send_headers(nil, headers)
152
+ @stream.send_headers(nil, interim_response_headers)
153
153
  end
154
154
  end
155
155
  end
@@ -38,18 +38,25 @@ module Async
38
38
 
39
39
  # This should be invoked from the background reader, and notifies the task waiting for the headers that we are done.
40
40
  def receive_initial_headers(headers, end_stream)
41
+ # While in theory, the response pseudo-headers may be extended in the future, currently they only response pseudo-header is :status, so we can assume it is always the first header.
42
+ status_header = headers.shift
43
+
44
+ if status_header.first != ':status'
45
+ raise ProtocolError, "Invalid response headers: #{headers.inspect}"
46
+ end
47
+
48
+ status = Integer(status_header.last)
49
+
50
+ if status >= 100 && status < 200
51
+ return receive_interim_headers(status, headers)
52
+ end
53
+
54
+ @response.status = status
55
+ @headers = ::Protocol::HTTP::Headers.new
56
+
41
57
  headers.each do |key, value|
42
58
  # It's guaranteed that this should be the first header:
43
- if key == STATUS
44
- status = Integer(value)
45
-
46
- # Ignore informational headers:
47
- return if status >= 100 && status < 200
48
-
49
- @response.status = Integer(value)
50
- elsif key == PROTOCOL
51
- @response.protocol = value
52
- elsif key == CONTENT_LENGTH
59
+ if key == CONTENT_LENGTH
53
60
  @length = Integer(value)
54
61
  else
55
62
  add_header(key, value)
@@ -74,6 +81,16 @@ module Async
74
81
  return headers
75
82
  end
76
83
 
84
+ def receive_interim_headers(status, headers)
85
+ if headers.any?
86
+ headers = ::Protocol::HTTP::Headers[headers]
87
+ else
88
+ headers = nil
89
+ end
90
+
91
+ @response.request.send_interim_response(status, headers)
92
+ end
93
+
77
94
  # Notify anyone waiting on the response headers to be received (or failure).
78
95
  def notify!
79
96
  if notification = @notification
@@ -51,10 +51,9 @@ module Async
51
51
  end
52
52
 
53
53
  def process_headers(frame)
54
- if frame.end_stream? && @headers
54
+ if @headers and frame.end_stream?
55
55
  self.receive_trailing_headers(super, frame.end_stream?)
56
56
  else
57
- @headers ||= ::Protocol::HTTP::Headers.new
58
57
  self.receive_initial_headers(super, frame.end_stream?)
59
58
  end
60
59
 
@@ -25,7 +25,7 @@ module Async
25
25
  false
26
26
  end
27
27
 
28
- def write_interim_response(response)
28
+ def write_interim_response(status, headers = nil)
29
29
  end
30
30
 
31
31
  def peer
@@ -81,6 +81,7 @@ module Async
81
81
  end
82
82
 
83
83
  attributes = {
84
+ 'http.version': request.version,
84
85
  'http.method': request.method,
85
86
  'http.authority': request.authority,
86
87
  'http.scheme': request.scheme,
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module HTTP
8
- VERSION = "0.71.0"
8
+ VERSION = "0.73.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.71.0
4
+ version: 0.73.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -58,7 +58,7 @@ cert_chain:
58
58
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
59
59
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
60
60
  -----END CERTIFICATE-----
61
- date: 2024-08-26 00:00:00.000000000 Z
61
+ date: 2024-08-31 00:00:00.000000000 Z
62
62
  dependencies:
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: async
@@ -122,14 +122,14 @@ dependencies:
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '0.28'
125
+ version: '0.30'
126
126
  type: :runtime
127
127
  prerelease: false
128
128
  version_requirements: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '0.28'
132
+ version: '0.30'
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: protocol-http1
135
135
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file