excon 0.21.0 → 0.22.0
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 +1 -1
- data/README.md +13 -3
- data/changelog.txt +8 -0
- data/excon.gemspec +2 -2
- data/lib/excon.rb +1 -0
- data/lib/excon/connection.rb +17 -2
- data/lib/excon/constants.rb +2 -1
- data/lib/excon/errors.rb +1 -9
- data/lib/excon/middlewares/expects.rb +1 -1
- data/lib/excon/middlewares/mock.rb +0 -13
- metadata +43 -22
- checksums.yaml +0 -7
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -48,8 +48,15 @@ Both one-off and persistent connections support many other options. Here are a f
|
|
48
48
|
connection = Excon.new('http://geemus.com/')
|
49
49
|
connection.get(:query => {:foo => 'bar'})
|
50
50
|
|
51
|
-
# POST body
|
52
|
-
Excon.post('http://geemus.com',
|
51
|
+
# POST body encoded with application/x-www-form-urlencoded
|
52
|
+
Excon.post('http://geemus.com',
|
53
|
+
:body => 'language=ruby&class=fog',
|
54
|
+
:headers => { "Content-Type" => "application/x-www-form-urlencoded" })
|
55
|
+
|
56
|
+
# same again, but using URI to build the body of parameters
|
57
|
+
Excon.post('http://geemus.com',
|
58
|
+
:body => URI.encode_www_form(:language => 'ruby', :class => 'fog'),
|
59
|
+
:headers => { "Content-Type" => "application/x-www-form-urlencoded" })
|
53
60
|
|
54
61
|
# request accepts either symbols or strings
|
55
62
|
connection.request(:method => :get)
|
@@ -61,9 +68,12 @@ Both one-off and persistent connections support many other options. Here are a f
|
|
61
68
|
# this request can be repeated safely, retry up to 6 times
|
62
69
|
connection.request(:idempotent => true, :retry_limit => 6)
|
63
70
|
|
64
|
-
# opt
|
71
|
+
# opt-out of nonblocking operations for performance and/or as a workaround
|
65
72
|
connection.request(:nonblock => false)
|
66
73
|
|
74
|
+
# opt-in to omitting port from http:80 and https:443
|
75
|
+
connection.request(:omit_default_port => true)
|
76
|
+
|
67
77
|
# set longer connect_timeout (default is 60 seconds)
|
68
78
|
connection.request(:connect_timeout => 360)
|
69
79
|
|
data/changelog.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.22.0 05/17/2013
|
2
|
+
=================
|
3
|
+
|
4
|
+
remove request/response info from default error messages to avoid credential leaks
|
5
|
+
add option to omit default ports (http:80 and https:443)
|
6
|
+
add examples for form encoding
|
7
|
+
updates to facilitate streaming responses from middleware responses
|
8
|
+
|
1
9
|
0.21.0 05/04/2013
|
2
10
|
=================
|
3
11
|
|
data/excon.gemspec
CHANGED
@@ -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.
|
17
|
-
s.date = '2013-05-
|
16
|
+
s.version = '0.22.0'
|
17
|
+
s.date = '2013-05-17'
|
18
18
|
s.rubyforge_project = 'excon'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/excon.rb
CHANGED
data/lib/excon/connection.rb
CHANGED
@@ -106,7 +106,7 @@ module Excon
|
|
106
106
|
# start with "METHOD /path"
|
107
107
|
request = datum[:method].to_s.upcase << ' '
|
108
108
|
if @data[:proxy]
|
109
|
-
request << datum[:scheme] << '://' << @data[:host] <<
|
109
|
+
request << datum[:scheme] << '://' << @data[:host] << port_string(@data)
|
110
110
|
end
|
111
111
|
request << datum[:path]
|
112
112
|
|
@@ -197,6 +197,13 @@ module Excon
|
|
197
197
|
end
|
198
198
|
|
199
199
|
def response_call(datum)
|
200
|
+
if datum.has_key?(:response_block) && !datum[:response][:body].empty?
|
201
|
+
content_length = remaining = datum[:response][:body].bytesize
|
202
|
+
while remaining > 0
|
203
|
+
datum[:response_block].call(datum[:response][:body].slice!(0, [datum[:chunk_size], remaining].min), [remaining - datum[:chunk_size], 0].max, content_length)
|
204
|
+
remaining -= datum[:chunk_size]
|
205
|
+
end
|
206
|
+
end
|
200
207
|
datum
|
201
208
|
end
|
202
209
|
|
@@ -215,7 +222,8 @@ module Excon
|
|
215
222
|
datum = @data.merge(params)
|
216
223
|
invalid_keys_warning(params, VALID_CONNECTION_KEYS)
|
217
224
|
datum[:headers] = @data[:headers].merge(datum[:headers] || {})
|
218
|
-
|
225
|
+
|
226
|
+
datum[:headers]['Host'] ||= '' << datum[:host] << port_string(datum)
|
219
227
|
datum[:retries_remaining] ||= datum[:retry_limit]
|
220
228
|
|
221
229
|
# if path is empty or doesn't start with '/', insert one
|
@@ -385,5 +393,12 @@ module Excon
|
|
385
393
|
end
|
386
394
|
end
|
387
395
|
|
396
|
+
def port_string(datum)
|
397
|
+
if datum[:omit_default_port] && (datum[:scheme].casecmp('http') == 0 && datum[:port].to_i == 80) || (datum[:scheme].casecmp('https') == 0 && datum[:port].to_i == 443)
|
398
|
+
''
|
399
|
+
else
|
400
|
+
':' << datum[:port].to_s
|
401
|
+
end
|
402
|
+
end
|
388
403
|
end
|
389
404
|
end
|
data/lib/excon/constants.rb
CHANGED
@@ -50,6 +50,7 @@ module Excon
|
|
50
50
|
:middlewares,
|
51
51
|
:mock,
|
52
52
|
:nonblock,
|
53
|
+
:omit_default_port,
|
53
54
|
:password,
|
54
55
|
:path,
|
55
56
|
:pipeline,
|
@@ -71,7 +72,7 @@ module Excon
|
|
71
72
|
:write_timeout
|
72
73
|
]
|
73
74
|
|
74
|
-
VERSION = '0.
|
75
|
+
VERSION = '0.22.0'
|
75
76
|
|
76
77
|
unless ::IO.const_defined?(:WaitReadable)
|
77
78
|
class ::IO
|
data/lib/excon/errors.rb
CHANGED
@@ -121,15 +121,7 @@ module Excon
|
|
121
121
|
}
|
122
122
|
|
123
123
|
error, message = @errors[response[:status]] || [Excon::Errors::HTTPStatusError, 'Unknown']
|
124
|
-
|
125
|
-
# scrub authorization
|
126
|
-
request = request.dup
|
127
|
-
request.reject! {|key, value| [:connection, :stack].include?(key)}
|
128
|
-
if request.has_key?(:headers) && request[:headers].has_key?('Authorization')
|
129
|
-
request[:headers] = request[:headers].dup
|
130
|
-
request[:headers]['Authorization'] = REDACTED
|
131
|
-
end
|
132
|
-
error.new("Expected(#{request[:expects].inspect}) <=> Actual(#{response[:status]} #{message})\n request => #{request.inspect}\n response => #{response.inspect}", request, response)
|
124
|
+
error.new("Expected(#{request[:expects].inspect}) <=> Actual(#{response[:status]} #{message})", request, response)
|
133
125
|
end
|
134
126
|
|
135
127
|
end
|
@@ -33,19 +33,6 @@ module Excon
|
|
33
33
|
if stub_datum.has_key?(:headers)
|
34
34
|
datum[:response][:headers].merge!(stub_datum[:headers])
|
35
35
|
end
|
36
|
-
|
37
|
-
if datum[:expects] && ![*datum[:expects]].include?(datum[:response][:status])
|
38
|
-
# don't pass stuff into a block if there was an error
|
39
|
-
elsif datum.has_key?(:response_block) && datum[:response].has_key?(:body)
|
40
|
-
body = datum[:response].delete(:body)
|
41
|
-
content_length = remaining = body.bytesize
|
42
|
-
i = 0
|
43
|
-
while i < body.length
|
44
|
-
datum[:response_block].call(body[i, datum[:chunk_size]], [remaining - datum[:chunk_size], 0].max, content_length)
|
45
|
-
remaining -= datum[:chunk_size]
|
46
|
-
i += datum[:chunk_size]
|
47
|
-
end
|
48
|
-
end
|
49
36
|
else
|
50
37
|
# if we reach here no stubs matched
|
51
38
|
raise(Excon::Errors::StubNotFound.new('no stubs matched ' << datum.inspect))
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- dpiddy (Dan Peterson)
|
@@ -10,118 +11,134 @@ authors:
|
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
14
|
+
date: 2013-05-17 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: activesupport
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
18
20
|
requirements:
|
19
|
-
- - '>='
|
21
|
+
- - ! '>='
|
20
22
|
- !ruby/object:Gem::Version
|
21
23
|
version: '0'
|
22
24
|
type: :development
|
23
25
|
prerelease: false
|
24
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
25
28
|
requirements:
|
26
|
-
- - '>='
|
29
|
+
- - ! '>='
|
27
30
|
- !ruby/object:Gem::Version
|
28
31
|
version: '0'
|
29
32
|
- !ruby/object:Gem::Dependency
|
30
33
|
name: delorean
|
31
34
|
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
32
36
|
requirements:
|
33
|
-
- - '>='
|
37
|
+
- - ! '>='
|
34
38
|
- !ruby/object:Gem::Version
|
35
39
|
version: '0'
|
36
40
|
type: :development
|
37
41
|
prerelease: false
|
38
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
39
44
|
requirements:
|
40
|
-
- - '>='
|
45
|
+
- - ! '>='
|
41
46
|
- !ruby/object:Gem::Version
|
42
47
|
version: '0'
|
43
48
|
- !ruby/object:Gem::Dependency
|
44
49
|
name: eventmachine
|
45
50
|
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
46
52
|
requirements:
|
47
|
-
- - '>='
|
53
|
+
- - ! '>='
|
48
54
|
- !ruby/object:Gem::Version
|
49
55
|
version: '0'
|
50
56
|
type: :development
|
51
57
|
prerelease: false
|
52
58
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
53
60
|
requirements:
|
54
|
-
- - '>='
|
61
|
+
- - ! '>='
|
55
62
|
- !ruby/object:Gem::Version
|
56
63
|
version: '0'
|
57
64
|
- !ruby/object:Gem::Dependency
|
58
65
|
name: open4
|
59
66
|
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
60
68
|
requirements:
|
61
|
-
- - '>='
|
69
|
+
- - ! '>='
|
62
70
|
- !ruby/object:Gem::Version
|
63
71
|
version: '0'
|
64
72
|
type: :development
|
65
73
|
prerelease: false
|
66
74
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
67
76
|
requirements:
|
68
|
-
- - '>='
|
77
|
+
- - ! '>='
|
69
78
|
- !ruby/object:Gem::Version
|
70
79
|
version: '0'
|
71
80
|
- !ruby/object:Gem::Dependency
|
72
81
|
name: rake
|
73
82
|
requirement: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
74
84
|
requirements:
|
75
|
-
- - '>='
|
85
|
+
- - ! '>='
|
76
86
|
- !ruby/object:Gem::Version
|
77
87
|
version: '0'
|
78
88
|
type: :development
|
79
89
|
prerelease: false
|
80
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
81
92
|
requirements:
|
82
|
-
- - '>='
|
93
|
+
- - ! '>='
|
83
94
|
- !ruby/object:Gem::Version
|
84
95
|
version: '0'
|
85
96
|
- !ruby/object:Gem::Dependency
|
86
97
|
name: rdoc
|
87
98
|
requirement: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
88
100
|
requirements:
|
89
|
-
- - '>='
|
101
|
+
- - ! '>='
|
90
102
|
- !ruby/object:Gem::Version
|
91
103
|
version: '0'
|
92
104
|
type: :development
|
93
105
|
prerelease: false
|
94
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
95
108
|
requirements:
|
96
|
-
- - '>='
|
109
|
+
- - ! '>='
|
97
110
|
- !ruby/object:Gem::Version
|
98
111
|
version: '0'
|
99
112
|
- !ruby/object:Gem::Dependency
|
100
113
|
name: shindo
|
101
114
|
requirement: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
102
116
|
requirements:
|
103
|
-
- - '>='
|
117
|
+
- - ! '>='
|
104
118
|
- !ruby/object:Gem::Version
|
105
119
|
version: '0'
|
106
120
|
type: :development
|
107
121
|
prerelease: false
|
108
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
109
124
|
requirements:
|
110
|
-
- - '>='
|
125
|
+
- - ! '>='
|
111
126
|
- !ruby/object:Gem::Version
|
112
127
|
version: '0'
|
113
128
|
- !ruby/object:Gem::Dependency
|
114
129
|
name: sinatra
|
115
130
|
requirement: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
116
132
|
requirements:
|
117
|
-
- - '>='
|
133
|
+
- - ! '>='
|
118
134
|
- !ruby/object:Gem::Version
|
119
135
|
version: '0'
|
120
136
|
type: :development
|
121
137
|
prerelease: false
|
122
138
|
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
123
140
|
requirements:
|
124
|
-
- - '>='
|
141
|
+
- - ! '>='
|
125
142
|
- !ruby/object:Gem::Version
|
126
143
|
version: '0'
|
127
144
|
description: EXtended http(s) CONnections
|
@@ -203,25 +220,29 @@ files:
|
|
203
220
|
- tests/timeout_tests.rb
|
204
221
|
homepage: https://github.com/geemus/excon
|
205
222
|
licenses: []
|
206
|
-
metadata: {}
|
207
223
|
post_install_message:
|
208
224
|
rdoc_options:
|
209
225
|
- --charset=UTF-8
|
210
226
|
require_paths:
|
211
227
|
- lib
|
212
228
|
required_ruby_version: !ruby/object:Gem::Requirement
|
229
|
+
none: false
|
213
230
|
requirements:
|
214
|
-
- - '>='
|
231
|
+
- - ! '>='
|
215
232
|
- !ruby/object:Gem::Version
|
216
233
|
version: '0'
|
234
|
+
segments:
|
235
|
+
- 0
|
236
|
+
hash: -2062001769353405727
|
217
237
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
|
+
none: false
|
218
239
|
requirements:
|
219
|
-
- - '>='
|
240
|
+
- - ! '>='
|
220
241
|
- !ruby/object:Gem::Version
|
221
242
|
version: '0'
|
222
243
|
requirements: []
|
223
244
|
rubyforge_project: excon
|
224
|
-
rubygems_version:
|
245
|
+
rubygems_version: 1.8.23
|
225
246
|
signing_key:
|
226
247
|
specification_version: 2
|
227
248
|
summary: speed, persistence, http(s)
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 79d850549c9cd7933c1c9a05634c3a742a68fd7c
|
4
|
-
data.tar.gz: c0e139c9271d440f1904e7e48a1e63001025bcae
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: ca660fbb1fd12593fc7b8e7dc0527c36689dac4774e0ba812b56f0ba2fa75b400642552418d9c53075b7e51d12dc1e51b1b7897b0331b965cfe87a04dfe48780
|
7
|
-
data.tar.gz: f8d723abcc8c5db7b54d5863259f37732ea64b3a68f5f5395c38d91f517ff5d28c5a661f81338845ae6f20c393bdd6ea9186fc516e30b570e4666230773d05ad
|