excon 0.16.2 → 0.16.3

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/README.md CHANGED
@@ -76,9 +76,9 @@ You can make `Transfer-Encoding: chunked` requests by passing a block that will
76
76
  file = File.open('data')
77
77
 
78
78
  chunker = lambda do
79
- # Excon::CHUNK_SIZE defaults to 1048576, ie 1MB
79
+ # Excon.defaults[:chunk_size] defaults to 1048576, ie 1MB
80
80
  # to_s will convert the nil receieved after everything is read to the final empty chunk
81
- file.read(Excon::CHUNK_SIZE).to_s
81
+ file.read(Excon.defaults[:chunk_size]).to_s
82
82
  end
83
83
 
84
84
  Excon.post('http://geemus.com', :request_block => chunker)
@@ -13,8 +13,8 @@ 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.16.2'
17
- s.date = '2012-08-27'
16
+ s.version = '0.16.3'
17
+ s.date = '2012-09-20'
18
18
  s.rubyforge_project = 'excon'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -16,6 +16,7 @@ module Excon
16
16
  # @return [Hash] defaults for Excon connections
17
17
  def defaults
18
18
  @defaults ||= {
19
+ :chunk_size => CHUNK_SIZE || DEFAULT_CHUNK_SIZE,
19
20
  :connect_timeout => 60,
20
21
  :headers => {},
21
22
  :instrumentor_name => 'excon',
@@ -258,7 +258,7 @@ module Excon
258
258
  if params[:body].respond_to?(:binmode)
259
259
  params[:body].binmode
260
260
  end
261
- while chunk = params[:body].read(CHUNK_SIZE)
261
+ while chunk = params[:body].read(params[:chunk_size])
262
262
  socket.write(chunk)
263
263
  end
264
264
  end
@@ -340,9 +340,9 @@ module Excon
340
340
  content_length = remaining = body.bytesize
341
341
  i = 0
342
342
  while i < body.length
343
- params[:response_block].call(body[i, CHUNK_SIZE], [remaining - CHUNK_SIZE, 0].max, content_length)
344
- remaining -= CHUNK_SIZE
345
- i += CHUNK_SIZE
343
+ params[:response_block].call(body[i, params[:chunk_size]], [remaining - params[:chunk_size], 0].max, content_length)
344
+ remaining -= params[:chunk_size]
345
+ i += params[:chunk_size]
346
346
  end
347
347
  end
348
348
  return Excon::Response.new(response_attributes)
@@ -1,43 +1,29 @@
1
1
  module Excon
2
- unless const_defined?(:VERSION)
3
- VERSION = '0.16.2'
4
- end
5
2
 
6
- unless const_defined?(:CHUNK_SIZE)
7
- CHUNK_SIZE = 1048576 # 1 megabyte
8
- end
3
+ CR_NL = "\r\n"
9
4
 
10
- unless const_defined?(:CR_NL)
11
- CR_NL = "\r\n"
12
- end
5
+ DEFAULT_CA_FILE = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "data", "cacert.pem"))
13
6
 
14
- unless const_defined?(:DEFAULT_CA_FILE)
15
- DEFAULT_CA_FILE = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "data", "cacert.pem"))
16
- end
7
+ DEFAULT_CHUNK_SIZE = 1048576 # 1 megabyte
17
8
 
18
- unless const_defined?(:DEFAULT_RETRY_LIMIT)
19
- DEFAULT_RETRY_LIMIT = 4
9
+ # avoid overwrite if somebody has redefined
10
+ unless const_defined?(:CHUNK_SIZE)
11
+ CHUNK_SIZE = DEFAULT_CHUNK_SIZE
20
12
  end
21
13
 
22
- unless const_defined?(:FORCE_ENC)
23
- FORCE_ENC = CR_NL.respond_to?(:force_encoding)
24
- end
14
+ DEFAULT_RETRY_LIMIT = 4
25
15
 
26
- unless const_defined?(:HTTP_1_1)
27
- HTTP_1_1 = " HTTP/1.1\r\n"
28
- end
16
+ FORCE_ENC = CR_NL.respond_to?(:force_encoding)
29
17
 
30
- unless const_defined?(:HTTP_VERBS)
31
- HTTP_VERBS = %w{connect delete get head options post put trace}
32
- end
18
+ HTTP_1_1 = " HTTP/1.1\r\n"
33
19
 
34
- unless const_defined?(:HTTPS)
35
- HTTPS = 'https'
36
- end
20
+ HTTP_VERBS = %w{connect delete get head options post put trace}
37
21
 
38
- unless const_defined?(:NO_ENTITY)
39
- NO_ENTITY = [204, 205, 304].freeze
40
- end
22
+ HTTPS = 'https'
23
+
24
+ NO_ENTITY = [204, 205, 304].freeze
25
+
26
+ VERSION = '0.16.3'
41
27
 
42
28
  unless ::IO.const_defined?(:WaitReadable)
43
29
  class ::IO
@@ -50,4 +36,5 @@ module Excon
50
36
  module WaitWritable; end
51
37
  end
52
38
  end
39
+
53
40
  end
@@ -46,11 +46,11 @@ module Excon
46
46
  socket.read(2)
47
47
  elsif remaining = content_length
48
48
  while remaining > 0
49
- params[:response_block].call(socket.read([CHUNK_SIZE, remaining].min), [remaining - CHUNK_SIZE, 0].max, content_length)
50
- remaining -= CHUNK_SIZE
49
+ params[:response_block].call(socket.read([params[:chunk_size], remaining].min), [remaining - params[:chunk_size], 0].max, content_length)
50
+ remaining -= params[:chunk_size]
51
51
  end
52
52
  else
53
- while remaining = socket.read(CHUNK_SIZE)
53
+ while remaining = socket.read(params[:chunk_size])
54
54
  params[:response_block].call(remaining, remaining.length, content_length)
55
55
  end
56
56
  end
@@ -62,8 +62,8 @@ module Excon
62
62
  socket.read(2) # 2 == "/r/n".length
63
63
  elsif remaining = content_length
64
64
  while remaining > 0
65
- response.body << socket.read([CHUNK_SIZE, remaining].min)
66
- remaining -= CHUNK_SIZE
65
+ response.body << socket.read([params[:chunk_size], remaining].min)
66
+ remaining -= params[:chunk_size]
67
67
  end
68
68
  else
69
69
  response.body << socket.read
@@ -87,7 +87,7 @@ module Excon
87
87
  end
88
88
  else
89
89
  while true
90
- @read_buffer << @socket.read_nonblock(CHUNK_SIZE)
90
+ @read_buffer << @socket.read_nonblock(@params[:chunk_size])
91
91
  end
92
92
  end
93
93
  rescue OpenSSL::SSL::SSLError => error
@@ -132,9 +132,9 @@ Shindo.tests('Excon stubs') do
132
132
 
133
133
  Excon.stubs.clear
134
134
 
135
- tests("stub({}, {:body => 'x' * (Excon::CHUNK_SIZE + 1)})") do
135
+ tests("stub({}, {:body => 'x' * (Excon::DEFAULT_CHUNK_SIZE + 1)})") do
136
136
  connection = Excon.new('http://127.0.0.1:9292', :mock => true)
137
- Excon.stub({}, {:body => 'x' * (Excon::CHUNK_SIZE + 1)})
137
+ Excon.stub({}, {:body => 'x' * (Excon::DEFAULT_CHUNK_SIZE + 1)})
138
138
 
139
139
  test("with response_block") do
140
140
  chunks = []
@@ -142,7 +142,7 @@ Shindo.tests('Excon stubs') do
142
142
  chunks << chunk
143
143
  end
144
144
  connection.request(:method => :get, :path => '/content-length/100', :response_block => response_block)
145
- chunks == ['x' * Excon::CHUNK_SIZE, 'x']
145
+ chunks == ['x' * Excon::DEFAULT_CHUNK_SIZE, 'x']
146
146
  end
147
147
  end
148
148
 
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.16.2
4
+ version: 0.16.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-27 00:00:00.000000000 Z
14
+ date: 2012-09-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70244964150240 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,15 @@ dependencies:
23
23
  version: '0'
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *70244964150240
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: delorean
29
- requirement: &70244964163380 !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
30
35
  none: false
31
36
  requirements:
32
37
  - - ! '>='
@@ -34,10 +39,15 @@ dependencies:
34
39
  version: '0'
35
40
  type: :development
36
41
  prerelease: false
37
- version_requirements: *70244964163380
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: open4
40
- requirement: &70244964162220 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ! '>='
@@ -45,10 +55,15 @@ dependencies:
45
55
  version: '0'
46
56
  type: :development
47
57
  prerelease: false
48
- version_requirements: *70244964162220
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
49
64
  - !ruby/object:Gem::Dependency
50
65
  name: rake
51
- requirement: &70244964160980 !ruby/object:Gem::Requirement
66
+ requirement: !ruby/object:Gem::Requirement
52
67
  none: false
53
68
  requirements:
54
69
  - - ! '>='
@@ -56,10 +71,15 @@ dependencies:
56
71
  version: '0'
57
72
  type: :development
58
73
  prerelease: false
59
- version_requirements: *70244964160980
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
60
80
  - !ruby/object:Gem::Dependency
61
81
  name: rdoc
62
- requirement: &70244964159980 !ruby/object:Gem::Requirement
82
+ requirement: !ruby/object:Gem::Requirement
63
83
  none: false
64
84
  requirements:
65
85
  - - ! '>='
@@ -67,10 +87,15 @@ dependencies:
67
87
  version: '0'
68
88
  type: :development
69
89
  prerelease: false
70
- version_requirements: *70244964159980
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
71
96
  - !ruby/object:Gem::Dependency
72
97
  name: shindo
73
- requirement: &70244964159080 !ruby/object:Gem::Requirement
98
+ requirement: !ruby/object:Gem::Requirement
74
99
  none: false
75
100
  requirements:
76
101
  - - ! '>='
@@ -78,10 +103,15 @@ dependencies:
78
103
  version: '0'
79
104
  type: :development
80
105
  prerelease: false
81
- version_requirements: *70244964159080
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
82
112
  - !ruby/object:Gem::Dependency
83
113
  name: sinatra
84
- requirement: &70244964157680 !ruby/object:Gem::Requirement
114
+ requirement: !ruby/object:Gem::Requirement
85
115
  none: false
86
116
  requirements:
87
117
  - - ! '>='
@@ -89,7 +119,12 @@ dependencies:
89
119
  version: '0'
90
120
  type: :development
91
121
  prerelease: false
92
- version_requirements: *70244964157680
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
93
128
  description: EXtended http(s) CONnections
94
129
  email: geemus@gmail.com
95
130
  executables: []
@@ -169,7 +204,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
204
  version: '0'
170
205
  segments:
171
206
  - 0
172
- hash: -3145610774015695237
207
+ hash: -910496643222039172
173
208
  required_rubygems_version: !ruby/object:Gem::Requirement
174
209
  none: false
175
210
  requirements:
@@ -178,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
213
  version: '0'
179
214
  requirements: []
180
215
  rubyforge_project: excon
181
- rubygems_version: 1.8.15
216
+ rubygems_version: 1.8.23
182
217
  signing_key:
183
218
  specification_version: 2
184
219
  summary: speed, persistence, http(s)