excon 0.13.1 → 0.13.2

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.

@@ -1,3 +1,8 @@
1
+ 0.13.2 03/26/12
2
+ ===============
3
+
4
+ * fix to avoid issues when Tempfile is not required/defined. Thanks nextmat
5
+
1
6
  0.13.1 03/26/12
2
7
  ===============
3
8
 
@@ -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.13.1'
16
+ s.version = '0.13.2'
17
17
  s.date = '2012-03-26'
18
18
  s.rubyforge_project = 'excon'
19
19
 
@@ -145,6 +145,21 @@ module Excon
145
145
 
146
146
  private
147
147
 
148
+ def detect_content_length(body)
149
+ if body.respond_to?(:binmode)
150
+ # IO object: File, Tempfile, etc.
151
+ body.binmode
152
+ File.size(body)
153
+ elsif body.is_a?(String)
154
+ if FORCE_ENC
155
+ body.force_encoding('BINARY')
156
+ end
157
+ body.length
158
+ else
159
+ 0
160
+ end
161
+ end
162
+
148
163
  def request_kernel(params)
149
164
  begin
150
165
  response = if params[:mock]
@@ -184,18 +199,7 @@ module Excon
184
199
  elsif ! (params[:method].to_s.casecmp('GET') == 0 && params[:body].nil?)
185
200
  # The HTTP spec isn't clear on it, but specifically, GET requests don't usually send bodies;
186
201
  # if they don't, sending Content-Length:0 can cause issues.
187
- params[:headers]['Content-Length'] = case params[:body]
188
- when File, Tempfile
189
- params[:body].binmode
190
- File.size(params[:body])
191
- when String
192
- if FORCE_ENC
193
- params[:body].force_encoding('BINARY')
194
- end
195
- params[:body].length
196
- else
197
- 0
198
- end
202
+ params[:headers]['Content-Length'] = detect_content_length(params[:body])
199
203
  end
200
204
 
201
205
  # add headers to request
@@ -1,6 +1,6 @@
1
1
  module Excon
2
2
  unless const_defined?(:VERSION)
3
- VERSION = '0.13.1'
3
+ VERSION = '0.13.2'
4
4
  end
5
5
 
6
6
  unless const_defined?(:CHUNK_SIZE)
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.13.1
4
+ version: 0.13.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2012-03-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70201828051100 !ruby/object:Gem::Requirement
18
+ requirement: &70350701665240 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *70201828051100
26
+ version_requirements: *70350701665240
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: delorean
29
- requirement: &70201828050080 !ruby/object:Gem::Requirement
29
+ requirement: &70350701664560 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *70201828050080
37
+ version_requirements: *70350701664560
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: open4
40
- requirement: &70201828049280 !ruby/object:Gem::Requirement
40
+ requirement: &70350701658060 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70201828049280
48
+ version_requirements: *70350701658060
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rake
51
- requirement: &70201828048840 !ruby/object:Gem::Requirement
51
+ requirement: &70350701657600 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *70201828048840
59
+ version_requirements: *70350701657600
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rdoc
62
- requirement: &70201828048420 !ruby/object:Gem::Requirement
62
+ requirement: &70350701657120 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *70201828048420
70
+ version_requirements: *70350701657120
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: shindo
73
- requirement: &70201828047800 !ruby/object:Gem::Requirement
73
+ requirement: &70350701656540 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70201828047800
81
+ version_requirements: *70350701656540
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: sinatra
84
- requirement: &70201828047240 !ruby/object:Gem::Requirement
84
+ requirement: &70350701655960 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,7 +89,7 @@ dependencies:
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *70201828047240
92
+ version_requirements: *70350701655960
93
93
  description: EXtended http(s) CONnections
94
94
  email: geemus@gmail.com
95
95
  executables: []