excon 0.93.1 → 0.94.0
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 +4 -4
- data/lib/excon/socket.rb +33 -17
- data/lib/excon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d70a84195cac612e187bcd007f341f4fbac5486f19cfd74b2389a166fa45837a
|
4
|
+
data.tar.gz: '05950bcb9e7cc752aeff9dc15201e5abee70636ed75f703fdfc2b28bdd97b68d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83711465351dcf3bd976aef38208b27d4704d2cfb35d67f4be0f0d732cd4ee4e164bfab1c3a0f8ac5f6db6fe14179c7c7a932431392a6fe56c87b3f89814a6e6
|
7
|
+
data.tar.gz: d28d63ee0decef91a3ac94d6919a66db17d4dbf64687cfb8ecb4a52a420511e9d97e9e7929f01bb5e6624abf7d6aef874ffce2736ae25cb0e038c5f4f8e577d7
|
data/lib/excon/socket.rb
CHANGED
@@ -40,12 +40,14 @@ module Excon
|
|
40
40
|
|
41
41
|
def_delegators(:@socket, :close)
|
42
42
|
|
43
|
+
|
43
44
|
def initialize(data = {})
|
44
45
|
@data = data
|
45
46
|
@nonblock = data[:nonblock]
|
46
47
|
@port ||= @data[:port] || 80
|
47
48
|
@read_buffer = String.new
|
48
49
|
@eof = false
|
50
|
+
@backend_eof = false
|
49
51
|
connect
|
50
52
|
end
|
51
53
|
|
@@ -61,9 +63,22 @@ module Excon
|
|
61
63
|
|
62
64
|
def readline
|
63
65
|
if @nonblock && RUBY_VERSION.to_f > 1.8_7
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
result = String.new
|
67
|
+
block = @read_buffer
|
68
|
+
@read_buffer = String.new
|
69
|
+
|
70
|
+
loop do
|
71
|
+
idx = block.index("\n")
|
72
|
+
if idx.nil?
|
73
|
+
result << block
|
74
|
+
else
|
75
|
+
add_to_read_buffer(block.slice!(idx+1, block.length))
|
76
|
+
result << block
|
77
|
+
break
|
78
|
+
end
|
79
|
+
block = read_nonblock(@data[:chunk_size]) || raise(EOFError)
|
80
|
+
end
|
81
|
+
result
|
67
82
|
else # nonblock/legacy
|
68
83
|
begin
|
69
84
|
Timeout.timeout(@data[:read_timeout]) do
|
@@ -172,20 +187,21 @@ module Excon
|
|
172
187
|
end
|
173
188
|
end
|
174
189
|
|
190
|
+
def add_to_read_buffer(str)
|
191
|
+
@read_buffer << str
|
192
|
+
@eof = false
|
193
|
+
end
|
194
|
+
|
175
195
|
def read_nonblock(max_length)
|
176
196
|
begin
|
177
|
-
|
178
|
-
|
179
|
-
@read_buffer << @socket.read_nonblock(max_length - @read_buffer.length)
|
180
|
-
end
|
181
|
-
else
|
182
|
-
loop do
|
183
|
-
@read_buffer << @socket.read_nonblock(@data[:chunk_size])
|
184
|
-
end
|
197
|
+
while !@backend_eof && (!max_length || @read_buffer.length < max_length)
|
198
|
+
@read_buffer << @socket.read_nonblock(@data[:chunk_size])
|
185
199
|
end
|
186
200
|
rescue OpenSSL::SSL::SSLError => error
|
187
201
|
if error.message == 'read would block'
|
188
|
-
|
202
|
+
if @read_buffer.empty?
|
203
|
+
select_with_timeout(@socket, :read) && retry
|
204
|
+
end
|
189
205
|
else
|
190
206
|
raise(error)
|
191
207
|
end
|
@@ -195,10 +211,10 @@ module Excon
|
|
195
211
|
select_with_timeout(@socket, :read) && retry
|
196
212
|
end
|
197
213
|
rescue EOFError
|
198
|
-
@
|
214
|
+
@backend_eof = true
|
199
215
|
end
|
200
216
|
|
201
|
-
if max_length
|
217
|
+
ret = if max_length
|
202
218
|
if @read_buffer.empty?
|
203
219
|
nil # EOF met at beginning
|
204
220
|
else
|
@@ -208,6 +224,8 @@ module Excon
|
|
208
224
|
# read until EOFError, so return everything
|
209
225
|
@read_buffer.slice!(0, @read_buffer.length)
|
210
226
|
end
|
227
|
+
@eof = @backend_eof && @read_buffer.empty?
|
228
|
+
ret
|
211
229
|
end
|
212
230
|
|
213
231
|
def read_block(max_length)
|
@@ -219,9 +237,7 @@ module Excon
|
|
219
237
|
raise(error)
|
220
238
|
end
|
221
239
|
rescue *READ_RETRY_EXCEPTION_CLASSES
|
222
|
-
|
223
|
-
select_with_timeout(@socket, :read) && retry
|
224
|
-
end
|
240
|
+
select_with_timeout(@socket, :read) && retry
|
225
241
|
rescue EOFError
|
226
242
|
@eof = true
|
227
243
|
end
|
data/lib/excon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.94.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dpiddy (Dan Peterson)
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-11-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|