async-http 0.56.5 → 0.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/http/body/hijack.rb +10 -12
- data/lib/async/http/client.rb +42 -0
- data/lib/async/http/endpoint.rb +4 -4
- data/lib/async/http/internet.rb +8 -0
- data/lib/async/http/protocol/http1/client.rb +1 -0
- data/lib/async/http/protocol/http1/request.rb +4 -1
- data/lib/async/http/protocol/http1/response.rb +3 -1
- data/lib/async/http/protocol/http1/server.rb +50 -45
- data/lib/async/http/protocol/http2/output.rb +2 -2
- data/lib/async/http/protocol/http2/stream.rb +3 -10
- data/lib/async/http/relative_location.rb +3 -3
- data/lib/async/http/server.rb +40 -1
- data/lib/async/http/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +75 -18
- metadata.gz.sig +0 -0
- data/lib/async/http/body/stream.rb +0 -172
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 238edc4ed5e4244f2060e9c788aa93588f9b3dd920646c8ec9161512af381e96
|
4
|
+
data.tar.gz: c77506488fedd3fec5a20d1172f1a2e6e6285f2c0dccb6a447a217a2e3423bc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87247dfbc7b31ead28e1fef6f6b532a6db22778eb3c0bde7932cdf6655027309ef1f0f1453b8a72d4ff38aabe3aeb9d8c7c75af28f8d35285bf6644f23655e99
|
7
|
+
data.tar.gz: bc199930224287caaea2c2b2c9b7219d81d24872932efa0a85b7bcada7d7c56b8f1da827ce34742db7bfc7193a72148a233cef09a65892d36949c5200f288e0a
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -21,7 +21,9 @@
|
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
23
|
require 'protocol/http/body/readable'
|
24
|
-
|
24
|
+
require 'protocol/http/body/stream'
|
25
|
+
|
26
|
+
require_relative 'writable'
|
25
27
|
|
26
28
|
module Async
|
27
29
|
module HTTP
|
@@ -42,6 +44,7 @@ module Async
|
|
42
44
|
|
43
45
|
@task = nil
|
44
46
|
@stream = nil
|
47
|
+
@output = nil
|
45
48
|
end
|
46
49
|
|
47
50
|
# We prefer streaming directly as it's the lowest overhead.
|
@@ -57,23 +60,18 @@ module Async
|
|
57
60
|
|
58
61
|
# Has the producer called #finish and has the reader consumed the nil token?
|
59
62
|
def empty?
|
60
|
-
|
61
|
-
@stream.empty?
|
62
|
-
else
|
63
|
-
false
|
64
|
-
end
|
63
|
+
@output&.empty?
|
65
64
|
end
|
66
65
|
|
67
66
|
def ready?
|
68
|
-
|
69
|
-
@stream.output.ready?
|
70
|
-
end
|
67
|
+
@output&.ready?
|
71
68
|
end
|
72
69
|
|
73
70
|
# Read the next available chunk.
|
74
71
|
def read
|
75
|
-
unless @
|
76
|
-
@
|
72
|
+
unless @output
|
73
|
+
@output = Writable.new
|
74
|
+
@stream = ::Protocol::HTTP::Body::Stream.new(@input, @output)
|
77
75
|
|
78
76
|
@task = Task.current.async do |task|
|
79
77
|
task.annotate "Streaming hijacked body."
|
@@ -82,7 +80,7 @@ module Async
|
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
85
|
-
return @
|
83
|
+
return @output.read
|
86
84
|
end
|
87
85
|
|
88
86
|
def inspect
|
data/lib/async/http/client.rb
CHANGED
@@ -28,6 +28,8 @@ require 'async/pool/controller'
|
|
28
28
|
require 'protocol/http/body/completable'
|
29
29
|
require 'protocol/http/methods'
|
30
30
|
|
31
|
+
require 'traces/provider'
|
32
|
+
|
31
33
|
require_relative 'protocol'
|
32
34
|
|
33
35
|
module Async
|
@@ -137,6 +139,46 @@ module Async
|
|
137
139
|
end
|
138
140
|
end
|
139
141
|
|
142
|
+
def inspect
|
143
|
+
"#<#{self.class} authority=#{@authority.inspect}>"
|
144
|
+
end
|
145
|
+
|
146
|
+
Traces::Provider(self) do
|
147
|
+
def call(request)
|
148
|
+
attributes = {
|
149
|
+
'http.method': request.method,
|
150
|
+
'http.authority': request.authority || self.authority,
|
151
|
+
'http.scheme': request.scheme || self.scheme,
|
152
|
+
'http.path': request.path,
|
153
|
+
}
|
154
|
+
|
155
|
+
if protocol = request.protocol
|
156
|
+
attributes['http.protocol'] = protocol
|
157
|
+
end
|
158
|
+
|
159
|
+
if length = request.body&.length
|
160
|
+
attributes['http.request.length'] = length
|
161
|
+
end
|
162
|
+
|
163
|
+
trace('async.http.client.call', attributes: attributes) do |span|
|
164
|
+
if context = trace_context(span)
|
165
|
+
request.headers['traceparent'] = context.to_s
|
166
|
+
# request.headers['tracestate'] = context.state
|
167
|
+
end
|
168
|
+
|
169
|
+
super.tap do |response|
|
170
|
+
if status = response&.status
|
171
|
+
span['http.status_code'] = status
|
172
|
+
end
|
173
|
+
|
174
|
+
if length = response.body&.length
|
175
|
+
span['http.response.length'] = length
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
140
182
|
protected
|
141
183
|
|
142
184
|
def make_response(request, connection)
|
data/lib/async/http/endpoint.rb
CHANGED
@@ -37,13 +37,13 @@ module Async
|
|
37
37
|
return self.new(url, endpoint, **options)
|
38
38
|
end
|
39
39
|
|
40
|
-
# Construct an endpoint with a specified scheme, hostname, and options.
|
41
|
-
def self.for(scheme, hostname, **options)
|
40
|
+
# Construct an endpoint with a specified scheme, hostname, optional path, and options.
|
41
|
+
def self.for(scheme, hostname, path = "/", **options)
|
42
42
|
# TODO: Consider using URI.for once it becomes available:
|
43
43
|
uri_klass = URI.scheme_list[scheme.upcase] || URI::HTTP
|
44
44
|
|
45
45
|
self.new(
|
46
|
-
uri_klass.new(scheme, nil, hostname, nil, nil,
|
46
|
+
uri_klass.new(scheme, nil, hostname, nil, nil, path, nil, nil, nil).normalize,
|
47
47
|
**options
|
48
48
|
)
|
49
49
|
end
|
@@ -241,4 +241,4 @@ module Async
|
|
241
241
|
end
|
242
242
|
end
|
243
243
|
end
|
244
|
-
end
|
244
|
+
end
|
data/lib/async/http/internet.rb
CHANGED
@@ -47,6 +47,14 @@ module Async
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
# Make a request to the internet with the given `method` and `url`.
|
51
|
+
#
|
52
|
+
# If you provide non-frozen headers, they may be mutated.
|
53
|
+
#
|
54
|
+
# @parameter method [String] The request method, e.g. `GET`.
|
55
|
+
# @parameter url [String] The URL to request, e.g. `https://www.codeotaku.com`.
|
56
|
+
# @parameter headers [Hash | Protocol::HTTP::Headers] The headers to send with the request.
|
57
|
+
# @parameter body [String | Protocol::HTTP::Body] The body to send with the request.
|
50
58
|
def call(method, url, headers = nil, body = nil)
|
51
59
|
endpoint = Endpoint.parse(url)
|
52
60
|
client = self.client_for(endpoint)
|
@@ -34,6 +34,7 @@ module Async
|
|
34
34
|
|
35
35
|
Console.logger.debug(self) {"#{request.method} #{request.path} #{request.headers.inspect}"}
|
36
36
|
|
37
|
+
# Mark the start of the trailers:
|
37
38
|
trailer = request.headers.trailer!
|
38
39
|
|
39
40
|
# We carefully interpret https://tools.ietf.org/html/rfc7230#section-6.3.1 to implement this correctly.
|
@@ -32,11 +32,14 @@ module Async
|
|
32
32
|
self.new(connection, *parts)
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
UPGRADE = 'upgrade'
|
35
37
|
|
36
38
|
def initialize(connection, authority, method, path, version, headers, body)
|
37
39
|
@connection = connection
|
38
40
|
|
39
|
-
|
41
|
+
# 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.
|
42
|
+
protocol = headers.delete('upgrade')
|
40
43
|
|
41
44
|
super(nil, authority, method, path, version, headers, body, protocol)
|
42
45
|
end
|
@@ -33,11 +33,13 @@ module Async
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
UPGRADE = 'upgrade'
|
37
|
+
|
36
38
|
# @param reason [String] HTTP response line reason, ignored.
|
37
39
|
def initialize(connection, version, status, reason, headers, body)
|
38
40
|
@connection = connection
|
39
41
|
|
40
|
-
protocol =
|
42
|
+
protocol = headers.delete(UPGRADE)
|
41
43
|
|
42
44
|
super(version, status, headers, body, protocol)
|
43
45
|
end
|
@@ -60,54 +60,59 @@ module Async
|
|
60
60
|
|
61
61
|
while request = next_request
|
62
62
|
response = yield(request, self)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
63
|
+
body = response&.body
|
64
|
+
|
65
|
+
begin
|
66
|
+
# If a response was generated, send it:
|
67
|
+
if response
|
68
|
+
trailer = response.headers.trailer!
|
69
|
+
|
70
|
+
write_response(@version, response.status, response.headers)
|
71
|
+
|
72
|
+
# Some operations in this method are long running, that is, it's expected that `body.call(stream)` could literally run indefinitely. In order to facilitate garbage collection, we want to nullify as many local variables before calling the streaming body. This ensures that the garbage collection can clean up as much state as possible during the long running operation, so we don't retain objects that are no longer needed.
|
73
|
+
|
74
|
+
if body and protocol = response.protocol
|
75
|
+
stream = write_upgrade_body(protocol)
|
76
|
+
|
77
|
+
# At this point, the request body is hijacked, so we don't want to call #finish below.
|
78
|
+
request = response = nil
|
79
|
+
|
80
|
+
body.call(stream)
|
81
|
+
elsif request.connect? and response.success?
|
82
|
+
stream = write_tunnel_body(request.version)
|
83
|
+
|
84
|
+
# Same as above:
|
85
|
+
request = response = nil
|
86
|
+
|
87
|
+
body.call(stream)
|
88
|
+
else
|
89
|
+
head = request.head?
|
90
|
+
version = request.version
|
91
|
+
|
92
|
+
# Same as above:
|
93
|
+
request = nil unless body
|
94
|
+
response = nil
|
95
|
+
|
96
|
+
write_body(version, body, head, trailer)
|
97
|
+
end
|
98
|
+
|
99
|
+
# We are done with the body, you shouldn't need to call close on it:
|
100
|
+
body = nil
|
91
101
|
else
|
92
|
-
|
93
|
-
version
|
94
|
-
|
95
|
-
request = nil unless body
|
96
|
-
response = nil
|
97
|
-
|
98
|
-
write_body(version, body, head, trailer)
|
102
|
+
# If the request failed to generate a response, it was an internal server error:
|
103
|
+
write_response(@version, 500, {})
|
104
|
+
write_body(request.version, nil)
|
99
105
|
end
|
100
|
-
|
101
|
-
#
|
102
|
-
|
103
|
-
|
106
|
+
|
107
|
+
# Gracefully finish reading the request body if it was not already done so.
|
108
|
+
request&.finish
|
109
|
+
|
110
|
+
# This ensures we yield at least once every iteration of the loop and allow other fibers to execute.
|
111
|
+
task.yield
|
112
|
+
rescue => error
|
113
|
+
ensure
|
114
|
+
body&.close(error)
|
104
115
|
end
|
105
|
-
|
106
|
-
# Gracefully finish reading the request body if it was not already done so.
|
107
|
-
request&.finish
|
108
|
-
|
109
|
-
# This ensures we yield at least once every iteration of the loop and allow other fibers to execute.
|
110
|
-
task.yield
|
111
116
|
end
|
112
117
|
end
|
113
118
|
end
|
@@ -20,7 +20,7 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
-
|
23
|
+
require 'protocol/http/body/stream'
|
24
24
|
|
25
25
|
module Async
|
26
26
|
module HTTP
|
@@ -88,7 +88,7 @@ module Async
|
|
88
88
|
|
89
89
|
input = @stream.wait_for_input
|
90
90
|
|
91
|
-
@body.call(Body::Stream.new(input, self))
|
91
|
+
@body.call(::Protocol::HTTP::Body::Stream.new(input, self))
|
92
92
|
rescue Async::Stop
|
93
93
|
# Ignore.
|
94
94
|
end
|
@@ -34,7 +34,6 @@ module Async
|
|
34
34
|
super
|
35
35
|
|
36
36
|
@headers = nil
|
37
|
-
@trailer = nil
|
38
37
|
|
39
38
|
# Input buffer, reading request body, or response body (receive_data):
|
40
39
|
@length = nil
|
@@ -62,11 +61,7 @@ module Async
|
|
62
61
|
|
63
62
|
def receive_trailing_headers(headers, end_stream)
|
64
63
|
headers.each do |key, value|
|
65
|
-
|
66
|
-
add_header(key, value)
|
67
|
-
else
|
68
|
-
raise ::Protocol::HTTP2::HeaderError, "Cannot add trailer #{key} as it was not specified as a trailer!"
|
69
|
-
end
|
64
|
+
add_header(key, value)
|
70
65
|
end
|
71
66
|
end
|
72
67
|
|
@@ -74,9 +69,7 @@ module Async
|
|
74
69
|
if @headers.nil?
|
75
70
|
@headers = ::Protocol::HTTP::Headers.new
|
76
71
|
self.receive_initial_headers(super, frame.end_stream?)
|
77
|
-
|
78
|
-
@trailer = @headers[TRAILER]
|
79
|
-
elsif @trailer and frame.end_stream?
|
72
|
+
elsif frame.end_stream?
|
80
73
|
self.receive_trailing_headers(super, frame.end_stream?)
|
81
74
|
else
|
82
75
|
raise ::Protocol::HTTP2::HeaderError, "Unable to process headers!"
|
@@ -152,7 +145,7 @@ module Async
|
|
152
145
|
send_reset_stream(::Protocol::HTTP2::Error::INTERNAL_ERROR)
|
153
146
|
else
|
154
147
|
# Write trailer?
|
155
|
-
if trailer
|
148
|
+
if trailer&.any?
|
156
149
|
send_headers(nil, trailer, ::Protocol::HTTP2::END_STREAM)
|
157
150
|
else
|
158
151
|
send_data(nil, ::Protocol::HTTP2::END_STREAM)
|
@@ -28,11 +28,11 @@ module Async
|
|
28
28
|
module HTTP
|
29
29
|
class TooManyRedirects < StandardError
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
# A client wrapper which transparently handles both relative and absolute redirects to a given maximum number of hops.
|
33
33
|
class RelativeLocation < ::Protocol::HTTP::Middleware
|
34
34
|
DEFAULT_METHOD = GET
|
35
|
-
|
35
|
+
|
36
36
|
# maximum_hops is the max number of redirects. Set to 0 to allow 1 request with no redirects.
|
37
37
|
def initialize(app, maximum_hops = 3)
|
38
38
|
super(app)
|
@@ -51,7 +51,7 @@ module Async
|
|
51
51
|
|
52
52
|
while hops <= @maximum_hops
|
53
53
|
response = super(request)
|
54
|
-
|
54
|
+
|
55
55
|
if response.redirection?
|
56
56
|
hops += 1
|
57
57
|
response.finish
|
data/lib/async/http/server.rb
CHANGED
@@ -23,9 +23,12 @@
|
|
23
23
|
require 'async/io/endpoint'
|
24
24
|
require 'async/io/stream'
|
25
25
|
|
26
|
-
require_relative 'protocol'
|
27
26
|
require 'protocol/http/middleware'
|
28
27
|
|
28
|
+
require 'traces/provider'
|
29
|
+
|
30
|
+
require_relative 'protocol'
|
31
|
+
|
29
32
|
module Async
|
30
33
|
module HTTP
|
31
34
|
class Server < ::Protocol::HTTP::Middleware
|
@@ -70,6 +73,42 @@ module Async
|
|
70
73
|
def run
|
71
74
|
@endpoint.accept(&self.method(:accept))
|
72
75
|
end
|
76
|
+
|
77
|
+
Traces::Provider(self) do
|
78
|
+
def call(request)
|
79
|
+
if trace_parent = request.headers['traceparent']
|
80
|
+
self.trace_context = Traces::Context.parse(trace_parent.join, request.headers['tracestate'], remote: true)
|
81
|
+
end
|
82
|
+
|
83
|
+
attributes = {
|
84
|
+
'http.method': request.method,
|
85
|
+
'http.authority': request.authority,
|
86
|
+
'http.scheme': request.scheme,
|
87
|
+
'http.path': request.path,
|
88
|
+
'http.user_agent': request.headers['user-agent'],
|
89
|
+
}
|
90
|
+
|
91
|
+
if length = request.body&.length
|
92
|
+
attributes['http.request.length'] = length
|
93
|
+
end
|
94
|
+
|
95
|
+
if protocol = request.protocol
|
96
|
+
attributes['http.protocol'] = protocol
|
97
|
+
end
|
98
|
+
|
99
|
+
trace('async.http.server.call', resource: "#{request.method} #{request.path}", attributes: attributes) do |span|
|
100
|
+
super.tap do |response|
|
101
|
+
if status = response&.status
|
102
|
+
span['http.status_code'] = status
|
103
|
+
end
|
104
|
+
|
105
|
+
if length = response&.body&.length
|
106
|
+
span['http.response.length'] = length
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
73
112
|
end
|
74
113
|
end
|
75
114
|
end
|
data/lib/async/http/version.rb
CHANGED
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.58.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
+
- Brian Morearty
|
9
|
+
- Bruno Sutic
|
10
|
+
- Janko Marohnić
|
11
|
+
- Adam Daniels
|
12
|
+
- Cyril Roelandt
|
13
|
+
- Denis Talakevich
|
14
|
+
- Ian Ker-Seymer
|
15
|
+
- Igor Sidorov
|
16
|
+
- Marco Concetto Rudilosso
|
17
|
+
- Olle Jonsson
|
18
|
+
- Orgad Shaneh
|
19
|
+
- Stefan Wrobel
|
20
|
+
- TheAthlete
|
21
|
+
- Trevor Turk
|
22
|
+
- samshadwell
|
8
23
|
autorequire:
|
9
24
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
25
|
+
cert_chain:
|
26
|
+
- |
|
27
|
+
-----BEGIN CERTIFICATE-----
|
28
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
29
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
30
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
31
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
32
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
33
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
34
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
35
|
+
9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
|
36
|
+
sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
|
37
|
+
e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
|
38
|
+
XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
|
39
|
+
RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
|
40
|
+
tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
|
41
|
+
zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
|
42
|
+
xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
43
|
+
BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
|
44
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
|
45
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
|
46
|
+
cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
|
47
|
+
xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
|
48
|
+
c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
|
49
|
+
8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
|
50
|
+
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
51
|
+
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
52
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
53
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
54
|
+
-----END CERTIFICATE-----
|
55
|
+
date: 2022-08-13 00:00:00.000000000 Z
|
12
56
|
dependencies:
|
13
57
|
- !ruby/object:Gem::Dependency
|
14
58
|
name: async
|
@@ -58,14 +102,14 @@ dependencies:
|
|
58
102
|
requirements:
|
59
103
|
- - "~>"
|
60
104
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
105
|
+
version: 0.23.1
|
62
106
|
type: :runtime
|
63
107
|
prerelease: false
|
64
108
|
version_requirements: !ruby/object:Gem::Requirement
|
65
109
|
requirements:
|
66
110
|
- - "~>"
|
67
111
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
112
|
+
version: 0.23.1
|
69
113
|
- !ruby/object:Gem::Dependency
|
70
114
|
name: protocol-http1
|
71
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +138,20 @@ dependencies:
|
|
94
138
|
- - "~>"
|
95
139
|
- !ruby/object:Gem::Version
|
96
140
|
version: 0.14.0
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: traces
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 0.4.0
|
148
|
+
type: :runtime
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 0.4.0
|
97
155
|
- !ruby/object:Gem::Dependency
|
98
156
|
name: async-container
|
99
157
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,7 +195,7 @@ dependencies:
|
|
137
195
|
- !ruby/object:Gem::Version
|
138
196
|
version: '0'
|
139
197
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
198
|
+
name: localhost
|
141
199
|
requirement: !ruby/object:Gem::Requirement
|
142
200
|
requirements:
|
143
201
|
- - ">="
|
@@ -151,33 +209,33 @@ dependencies:
|
|
151
209
|
- !ruby/object:Gem::Version
|
152
210
|
version: '0'
|
153
211
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
212
|
+
name: rack-test
|
155
213
|
requirement: !ruby/object:Gem::Requirement
|
156
214
|
requirements:
|
157
|
-
- - "
|
215
|
+
- - ">="
|
158
216
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
217
|
+
version: '0'
|
160
218
|
type: :development
|
161
219
|
prerelease: false
|
162
220
|
version_requirements: !ruby/object:Gem::Requirement
|
163
221
|
requirements:
|
164
|
-
- - "
|
222
|
+
- - ">="
|
165
223
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
224
|
+
version: '0'
|
167
225
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
226
|
+
name: rspec
|
169
227
|
requirement: !ruby/object:Gem::Requirement
|
170
228
|
requirements:
|
171
|
-
- - "
|
229
|
+
- - "~>"
|
172
230
|
- !ruby/object:Gem::Version
|
173
|
-
version: '
|
231
|
+
version: '3.6'
|
174
232
|
type: :development
|
175
233
|
prerelease: false
|
176
234
|
version_requirements: !ruby/object:Gem::Requirement
|
177
235
|
requirements:
|
178
|
-
- - "
|
236
|
+
- - "~>"
|
179
237
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
238
|
+
version: '3.6'
|
181
239
|
description:
|
182
240
|
email:
|
183
241
|
executables: []
|
@@ -192,7 +250,6 @@ files:
|
|
192
250
|
- lib/async/http/body/hijack.rb
|
193
251
|
- lib/async/http/body/pipe.rb
|
194
252
|
- lib/async/http/body/slowloris.rb
|
195
|
-
- lib/async/http/body/stream.rb
|
196
253
|
- lib/async/http/body/writable.rb
|
197
254
|
- lib/async/http/client.rb
|
198
255
|
- lib/async/http/endpoint.rb
|
@@ -244,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
301
|
- !ruby/object:Gem::Version
|
245
302
|
version: '0'
|
246
303
|
requirements: []
|
247
|
-
rubygems_version: 3.
|
304
|
+
rubygems_version: 3.3.7
|
248
305
|
signing_key:
|
249
306
|
specification_version: 4
|
250
307
|
summary: A HTTP client and server library.
|
metadata.gz.sig
ADDED
Binary file
|
@@ -1,172 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require_relative 'writable'
|
24
|
-
|
25
|
-
module Async
|
26
|
-
module HTTP
|
27
|
-
module Body
|
28
|
-
# The input stream is an IO-like object which contains the raw HTTP POST data. When applicable, its external encoding must be “ASCII-8BIT” and it must be opened in binary mode, for Ruby 1.9 compatibility. The input stream must respond to gets, each, read and rewind.
|
29
|
-
class Stream
|
30
|
-
def initialize(input, output = Writable.new)
|
31
|
-
@input = input
|
32
|
-
@output = output
|
33
|
-
|
34
|
-
raise ArgumentError, "Non-writable output!" unless output.respond_to?(:write)
|
35
|
-
|
36
|
-
# Will hold remaining data in `#read`.
|
37
|
-
@buffer = nil
|
38
|
-
@closed = false
|
39
|
-
end
|
40
|
-
|
41
|
-
attr :input
|
42
|
-
attr :output
|
43
|
-
|
44
|
-
# rack.hijack_io must respond to:
|
45
|
-
# read, write, read_nonblock, write_nonblock, flush, close, close_read, close_write, closed?
|
46
|
-
|
47
|
-
# read behaves like IO#read. Its signature is read([length, [buffer]]). If given, length must be a non-negative Integer (>= 0) or nil, and buffer must be a String and may not be nil. If length is given and not nil, then this method reads at most length bytes from the input stream. If length is not given or nil, then this method reads all data until EOF. When EOF is reached, this method returns nil if length is given and not nil, or “” if length is not given or is nil. If buffer is given, then the read data will be placed into buffer instead of a newly created String object.
|
48
|
-
# @param length [Integer] the amount of data to read
|
49
|
-
# @param buffer [String] the buffer which will receive the data
|
50
|
-
# @return a buffer containing the data
|
51
|
-
def read(size = nil, buffer = nil)
|
52
|
-
return '' if size == 0
|
53
|
-
|
54
|
-
buffer ||= Async::IO::Buffer.new
|
55
|
-
if @buffer
|
56
|
-
buffer.replace(@buffer)
|
57
|
-
@buffer = nil
|
58
|
-
end
|
59
|
-
|
60
|
-
if size
|
61
|
-
while buffer.bytesize < size and chunk = read_next
|
62
|
-
buffer << chunk
|
63
|
-
end
|
64
|
-
|
65
|
-
@buffer = buffer.byteslice(size, buffer.bytesize)
|
66
|
-
buffer = buffer.byteslice(0, size)
|
67
|
-
|
68
|
-
if buffer.empty?
|
69
|
-
return nil
|
70
|
-
else
|
71
|
-
return buffer
|
72
|
-
end
|
73
|
-
else
|
74
|
-
while chunk = read_next
|
75
|
-
buffer << chunk
|
76
|
-
end
|
77
|
-
|
78
|
-
return buffer
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# Read at most `size` bytes from the stream. Will avoid reading from the underlying stream if possible.
|
83
|
-
def read_partial(size = nil)
|
84
|
-
if @buffer
|
85
|
-
buffer = @buffer
|
86
|
-
@buffer = nil
|
87
|
-
else
|
88
|
-
buffer = read_next
|
89
|
-
end
|
90
|
-
|
91
|
-
if buffer and size
|
92
|
-
if buffer.bytesize > size
|
93
|
-
@buffer = buffer.byteslice(size, buffer.bytesize)
|
94
|
-
buffer = buffer.byteslice(0, size)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
return buffer
|
99
|
-
end
|
100
|
-
|
101
|
-
def read_nonblock(length, buffer = nil)
|
102
|
-
@buffer ||= read_next
|
103
|
-
chunk = nil
|
104
|
-
|
105
|
-
return nil if @buffer.nil?
|
106
|
-
|
107
|
-
if @buffer.bytesize > length
|
108
|
-
chunk = @buffer.byteslice(0, length)
|
109
|
-
@buffer = @buffer.byteslice(length, @buffer.bytesize)
|
110
|
-
else
|
111
|
-
chunk = @buffer
|
112
|
-
@buffer = nil
|
113
|
-
end
|
114
|
-
|
115
|
-
if buffer
|
116
|
-
buffer.replace(chunk)
|
117
|
-
else
|
118
|
-
buffer = chunk
|
119
|
-
end
|
120
|
-
|
121
|
-
return buffer
|
122
|
-
end
|
123
|
-
|
124
|
-
def write(buffer)
|
125
|
-
@output.write(buffer)
|
126
|
-
end
|
127
|
-
|
128
|
-
alias write_nonblock write
|
129
|
-
|
130
|
-
def flush
|
131
|
-
end
|
132
|
-
|
133
|
-
def close_read
|
134
|
-
@input&.close
|
135
|
-
end
|
136
|
-
|
137
|
-
def close_write
|
138
|
-
@output&.close
|
139
|
-
end
|
140
|
-
|
141
|
-
# Close the input and output bodies.
|
142
|
-
def close(error = nil)
|
143
|
-
self.close_read
|
144
|
-
self.close_write
|
145
|
-
ensure
|
146
|
-
@closed = true
|
147
|
-
end
|
148
|
-
|
149
|
-
# Whether the stream has been closed.
|
150
|
-
def closed?
|
151
|
-
@closed
|
152
|
-
end
|
153
|
-
|
154
|
-
# Whether there are any output chunks remaining?
|
155
|
-
def empty?
|
156
|
-
@output.empty?
|
157
|
-
end
|
158
|
-
|
159
|
-
private
|
160
|
-
|
161
|
-
def read_next
|
162
|
-
if chunk = @input&.read
|
163
|
-
return chunk
|
164
|
-
else
|
165
|
-
@input = nil
|
166
|
-
return nil
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|