async-http 0.56.6 → 0.57.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/endpoint.rb +3 -3
- data/lib/async/http/protocol/http2/output.rb +2 -2
- data/lib/async/http/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +30 -30
- 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: 454a678139fa72fafb6fc06cc34af7f21b44bba2a7ebddf7bfc823c01c5b968a
|
4
|
+
data.tar.gz: d91f30582707db6bd9a717d449c7d8295f8110b315defec4477b892e28678c22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0517cac618b852dca972400c943b7fc78ee7693ad1555eeb2699d5fc45a6fee0d4ceeb45121168955da3bdd980ebee788f21c51d42e3de5fba03a8896e3fb3fc
|
7
|
+
data.tar.gz: 321e705b70ab0efb1d36cc8614a6193b593c930badd96f239734685594da3456ee505e9dcc9c7fe28fc4ace349c25e4cff3774b5753d1c692769b21466d80de4
|
checksums.yaml.gz.sig
CHANGED
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/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
|
@@ -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
|
data/lib/async/http/version.rb
CHANGED
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.
|
4
|
+
version: 0.57.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -25,33 +25,34 @@ bindir: bin
|
|
25
25
|
cert_chain:
|
26
26
|
- |
|
27
27
|
-----BEGIN CERTIFICATE-----
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
28
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
29
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
30
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
31
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
32
|
+
MBsGCgm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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=
|
53
54
|
-----END CERTIFICATE-----
|
54
|
-
date: 2022-
|
55
|
+
date: 2022-08-07 00:00:00.000000000 Z
|
55
56
|
dependencies:
|
56
57
|
- !ruby/object:Gem::Dependency
|
57
58
|
name: async
|
@@ -101,14 +102,14 @@ dependencies:
|
|
101
102
|
requirements:
|
102
103
|
- - "~>"
|
103
104
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.
|
105
|
+
version: 0.23.1
|
105
106
|
type: :runtime
|
106
107
|
prerelease: false
|
107
108
|
version_requirements: !ruby/object:Gem::Requirement
|
108
109
|
requirements:
|
109
110
|
- - "~>"
|
110
111
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0.
|
112
|
+
version: 0.23.1
|
112
113
|
- !ruby/object:Gem::Dependency
|
113
114
|
name: protocol-http1
|
114
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,7 +250,6 @@ files:
|
|
249
250
|
- lib/async/http/body/hijack.rb
|
250
251
|
- lib/async/http/body/pipe.rb
|
251
252
|
- lib/async/http/body/slowloris.rb
|
252
|
-
- lib/async/http/body/stream.rb
|
253
253
|
- lib/async/http/body/writable.rb
|
254
254
|
- lib/async/http/client.rb
|
255
255
|
- lib/async/http/endpoint.rb
|
metadata.gz.sig
CHANGED
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
|