excon 0.19.0 → 0.19.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of excon might be problematic. Click here for more details.

data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- excon (0.19.0)
4
+ excon (0.19.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/changelog.txt CHANGED
@@ -1,3 +1,8 @@
1
+ 0.19.1 02/27/2013
2
+ =================
3
+
4
+ fix for ssl proxies to allow connect response to be read
5
+
1
6
  0.19.0 02/27/2013
2
7
  =================
3
8
 
data/excon.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'excon'
16
- s.version = '0.19.0'
16
+ s.version = '0.19.1'
17
17
  s.date = '2013-02-27'
18
18
  s.rubyforge_project = 'excon'
19
19
 
@@ -315,63 +315,7 @@ module Excon
315
315
 
316
316
  def response(datum={})
317
317
  unless datum.has_key?(:response)
318
- datum[:response] = {
319
- :body => '',
320
- :headers => {},
321
- :status => socket.read(12)[9, 11].to_i,
322
- :remote_ip => socket.remote_ip
323
- }
324
- socket.readline # read the rest of the status line and CRLF
325
-
326
- until ((data = socket.readline).chop!).empty?
327
- key, value = data.split(/:\s*/, 2)
328
- datum[:response][:headers][key] = ([*datum[:response][:headers][key]] << value).compact.join(', ')
329
- if key.casecmp('Content-Length') == 0
330
- content_length = value.to_i
331
- elsif (key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0)
332
- transfer_encoding_chunked = true
333
- end
334
- end
335
-
336
- unless (['HEAD', 'CONNECT'].include?(datum[:method].to_s.upcase)) || NO_ENTITY.include?(datum[:response][:status])
337
-
338
- # check to see if expects was set and matched
339
- expected_status = !datum.has_key?(:expects) || [*datum[:expects]].include?(datum[:response][:status])
340
-
341
- # if expects matched and there is a block, use it
342
- if expected_status && datum.has_key?(:response_block)
343
- if transfer_encoding_chunked
344
- # 2 == "/r/n".length
345
- while (chunk_size = socket.readline.chop!.to_i(16)) > 0
346
- datum[:response_block].call(socket.read(chunk_size + 2).chop!, nil, nil)
347
- end
348
- socket.read(2)
349
- elsif remaining = content_length
350
- while remaining > 0
351
- datum[:response_block].call(socket.read([datum[:chunk_size], remaining].min), [remaining - datum[:chunk_size], 0].max, content_length)
352
- remaining -= datum[:chunk_size]
353
- end
354
- else
355
- while remaining = socket.read(datum[:chunk_size])
356
- datum[:response_block].call(remaining, remaining.length, content_length)
357
- end
358
- end
359
- else # no block or unexpected status
360
- if transfer_encoding_chunked
361
- while (chunk_size = socket.readline.chop!.to_i(16)) > 0
362
- datum[:response][:body] << socket.read(chunk_size + 2).chop! # 2 == "/r/n".length
363
- end
364
- socket.read(2) # 2 == "/r/n".length
365
- elsif remaining = content_length
366
- while remaining > 0
367
- datum[:response][:body] << socket.read([datum[:chunk_size], remaining].min)
368
- remaining -= datum[:chunk_size]
369
- end
370
- else
371
- datum[:response][:body] << socket.read
372
- end
373
- end
374
- end
318
+ datum = Excon::Response.parse(socket, datum)
375
319
  end
376
320
 
377
321
  datum[:stack].response_call(datum)
@@ -69,7 +69,7 @@ module Excon
69
69
  :write_timeout
70
70
  ]
71
71
 
72
- VERSION = '0.19.0'
72
+ VERSION = '0.19.1'
73
73
 
74
74
  unless ::IO.const_defined?(:WaitReadable)
75
75
  class ::IO
@@ -29,6 +29,67 @@ module Excon
29
29
  @data[:remote_ip]
30
30
  end
31
31
 
32
+ def self.parse(socket, datum)
33
+ datum[:response] = {
34
+ :body => '',
35
+ :headers => {},
36
+ :status => socket.read(12)[9, 11].to_i,
37
+ :remote_ip => socket.remote_ip
38
+ }
39
+ socket.readline # read the rest of the status line and CRLF
40
+
41
+ until ((data = socket.readline).chop!).empty?
42
+ key, value = data.split(/:\s*/, 2)
43
+ datum[:response][:headers][key] = ([*datum[:response][:headers][key]] << value).compact.join(', ')
44
+ if key.casecmp('Content-Length') == 0
45
+ content_length = value.to_i
46
+ elsif (key.casecmp('Transfer-Encoding') == 0) && (value.casecmp('chunked') == 0)
47
+ transfer_encoding_chunked = true
48
+ end
49
+ end
50
+
51
+ unless (['HEAD', 'CONNECT'].include?(datum[:method].to_s.upcase)) || NO_ENTITY.include?(datum[:response][:status])
52
+
53
+ # check to see if expects was set and matched
54
+ expected_status = !datum.has_key?(:expects) || [*datum[:expects]].include?(datum[:response][:status])
55
+
56
+ # if expects matched and there is a block, use it
57
+ if expected_status && datum.has_key?(:response_block)
58
+ if transfer_encoding_chunked
59
+ # 2 == "/r/n".length
60
+ while (chunk_size = socket.readline.chop!.to_i(16)) > 0
61
+ datum[:response_block].call(socket.read(chunk_size + 2).chop!, nil, nil)
62
+ end
63
+ socket.read(2)
64
+ elsif remaining = content_length
65
+ while remaining > 0
66
+ datum[:response_block].call(socket.read([datum[:chunk_size], remaining].min), [remaining - datum[:chunk_size], 0].max, content_length)
67
+ remaining -= datum[:chunk_size]
68
+ end
69
+ else
70
+ while remaining = socket.read(datum[:chunk_size])
71
+ datum[:response_block].call(remaining, remaining.length, content_length)
72
+ end
73
+ end
74
+ else # no block or unexpected status
75
+ if transfer_encoding_chunked
76
+ while (chunk_size = socket.readline.chop!.to_i(16)) > 0
77
+ datum[:response][:body] << socket.read(chunk_size + 2).chop! # 2 == "/r/n".length
78
+ end
79
+ socket.read(2) # 2 == "/r/n".length
80
+ elsif remaining = content_length
81
+ while remaining > 0
82
+ datum[:response][:body] << socket.read([datum[:chunk_size], remaining].min)
83
+ remaining -= datum[:chunk_size]
84
+ end
85
+ else
86
+ datum[:response][:body] << socket.read
87
+ end
88
+ end
89
+ end
90
+ datum
91
+ end
92
+
32
93
  def initialize(params={})
33
94
  @data = {
34
95
  :body => '',
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.19.0
4
+ version: 0.19.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -230,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
230
230
  version: '0'
231
231
  segments:
232
232
  - 0
233
- hash: 4361906214434444580
233
+ hash: 518823091680124147
234
234
  required_rubygems_version: !ruby/object:Gem::Requirement
235
235
  none: false
236
236
  requirements: