excon 0.0.12 → 0.0.13
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.
Potentially problematic release.
This version of excon might be problematic. Click here for more details.
- data/VERSION +1 -1
- data/excon.gemspec +1 -1
- data/lib/excon/connection.rb +7 -5
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/excon.gemspec
CHANGED
data/lib/excon/connection.rb
CHANGED
@@ -51,15 +51,17 @@ unless Excon.mocking?
|
|
51
51
|
end
|
52
52
|
|
53
53
|
unless params[:method] == 'HEAD'
|
54
|
-
if !params[:block] || (params[:expects] && ![*params[:expects]].include?(response.status))
|
54
|
+
block = if !params[:block] || (params[:expects] && ![*params[:expects]].include?(response.status))
|
55
55
|
response.body = ''
|
56
|
-
|
56
|
+
lambda { |chunk| response.body << chunk }
|
57
|
+
else
|
58
|
+
params[:block]
|
57
59
|
end
|
58
60
|
|
59
61
|
if response.headers['Content-Length']
|
60
62
|
remaining = response.headers['Content-Length'].to_i
|
61
63
|
while remaining > 0
|
62
|
-
|
64
|
+
block.call(connection.read([CHUNK_SIZE, remaining].min))
|
63
65
|
remaining -= CHUNK_SIZE
|
64
66
|
end
|
65
67
|
elsif response.headers['Transfer-Encoding'] == 'chunked'
|
@@ -67,13 +69,13 @@ unless Excon.mocking?
|
|
67
69
|
chunk_size = connection.readline.chop!.to_i(16)
|
68
70
|
chunk = connection.read(chunk_size + 2).chop! # 2 == "/r/n".length
|
69
71
|
if chunk_size > 0
|
70
|
-
|
72
|
+
block.call(chunk)
|
71
73
|
else
|
72
74
|
break
|
73
75
|
end
|
74
76
|
end
|
75
77
|
elsif response.headers['Connection'] == 'close'
|
76
|
-
|
78
|
+
block.call(connection.read)
|
77
79
|
Thread.current[:_excon_connection] = nil
|
78
80
|
end
|
79
81
|
end
|