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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8a62982c0ca9bd57cf326b34e0f697a6fac7af99de50cf98fe36b7cc93fb4cd
4
- data.tar.gz: 16e52379346b1d2e7a9ad115c1859c8c8ba3c3e229e2f1a6385eaf9f5477ca12
3
+ metadata.gz: 454a678139fa72fafb6fc06cc34af7f21b44bba2a7ebddf7bfc823c01c5b968a
4
+ data.tar.gz: d91f30582707db6bd9a717d449c7d8295f8110b315defec4477b892e28678c22
5
5
  SHA512:
6
- metadata.gz: f0d95e9e50f34b39a8725ef5cef5b8affb7a3feee22eda029e5c064ca7afd254aa77d2ce5fba65d0a8903e8c65875a6e3756fa98a204725f322a2e2c3fb0c570
7
- data.tar.gz: 71c38354bd9ce92fb507bd7e36b0e557fb7073eeb30fcbba1c44511ac1d9cf96d5ca6e0c8556e86b036b4dc53fb3fd394eaf7975f16b8509e50cbdd58c1de399
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
- require_relative 'stream'
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
- if @stream
61
- @stream.empty?
62
- else
63
- false
64
- end
63
+ @output&.empty?
65
64
  end
66
65
 
67
66
  def ready?
68
- if @stream
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 @task
76
- @stream = Stream.new(@input)
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 @stream.output.read
83
+ return @output.read
86
84
  end
87
85
 
88
86
  def inspect
@@ -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, nil, nil, nil, nil).normalize,
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
- require_relative '../../body/stream'
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
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Async
24
24
  module HTTP
25
- VERSION = "0.56.6"
25
+ VERSION = "0.57.0"
26
26
  end
27
27
  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.56.6
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
- MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
29
- ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
30
- MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
31
- aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
32
- AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
33
- xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
34
- eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
35
- L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
36
- 9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
37
- E/mljo4zEVKhlTWpJklMIhr55ZRrSarKFuW7en0+tpJrfsYiAmXMJNi4XAYJH7uL
38
- rgJuJwSaa/dMz+VmUoo7VKtSfCoOI+6v5/z0sK3oT6sG6ZwyI47DBq2XqNC6tnAj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AA4IBgQB5sxkE
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=
53
54
  -----END CERTIFICATE-----
54
- date: 2022-05-02 00:00:00.000000000 Z
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.22.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.22.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