excon 0.2.6 → 0.2.7
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/excon.gemspec +2 -2
- data/lib/excon.rb +1 -1
- data/lib/excon/connection.rb +3 -2
- data/lib/excon/errors.rb +54 -43
- data/lib/excon/response.rb +1 -1
- metadata +3 -3
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.2.
|
17
|
-
s.date = '2010-11-
|
16
|
+
s.version = '0.2.7'
|
17
|
+
s.date = '2010-11-30'
|
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
@@ -102,7 +102,7 @@ module Excon
|
|
102
102
|
response
|
103
103
|
rescue => socket_error
|
104
104
|
reset
|
105
|
-
raise(socket_error)
|
105
|
+
raise(Excon::Errors::SocketError.new(socket_error))
|
106
106
|
end
|
107
107
|
|
108
108
|
if params[:expects] && ![*params[:expects]].include?(response.status)
|
@@ -114,7 +114,8 @@ module Excon
|
|
114
114
|
|
115
115
|
rescue => request_error
|
116
116
|
if params[:idempotent] &&
|
117
|
-
(
|
117
|
+
(request_error.is_a?(Excon::Errors::SocketError) ||
|
118
|
+
(request_error.is_a?(Excon::Errors::HTTPStatusError) && response.status != 404))
|
118
119
|
retries_remaining ||= 4
|
119
120
|
retries_remaining -= 1
|
120
121
|
if retries_remaining > 0
|
data/lib/excon/errors.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
module Excon
|
2
|
-
|
3
2
|
module Errors
|
4
|
-
|
3
|
+
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
class SocketError < Error
|
7
|
+
attr_reader :socket_error
|
8
|
+
|
9
|
+
def initialize(socket_error=nil)
|
10
|
+
super(socket_error.message)
|
11
|
+
@socket_error = socket_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class HTTPStatusError < Error
|
5
16
|
attr_reader :request, :response
|
6
17
|
|
7
18
|
def initialize(msg, request = nil, response = nil)
|
@@ -11,46 +22,46 @@ module Excon
|
|
11
22
|
end
|
12
23
|
end
|
13
24
|
|
14
|
-
class Continue <
|
15
|
-
class SwitchingProtocols <
|
16
|
-
class OK <
|
17
|
-
class Created <
|
18
|
-
class Accepted <
|
19
|
-
class NonAuthoritativeInformation <
|
20
|
-
class NoContent <
|
21
|
-
class ResetContent <
|
22
|
-
class PartialContent <
|
23
|
-
class MultipleChoices <
|
24
|
-
class MovedPermanently <
|
25
|
-
class Found <
|
26
|
-
class SeeOther <
|
27
|
-
class NotModified <
|
28
|
-
class UseProxy <
|
29
|
-
class TemporaryRedirect <
|
30
|
-
class BadRequest <
|
31
|
-
class Unauthorized <
|
32
|
-
class PaymentRequired <
|
33
|
-
class Forbidden <
|
34
|
-
class NotFound <
|
35
|
-
class MethodNotAllowed <
|
36
|
-
class NotAcceptable <
|
37
|
-
class ProxyAuthenticationRequired <
|
38
|
-
class RequestTimeout <
|
39
|
-
class Conflict <
|
40
|
-
class Gone <
|
41
|
-
class LengthRequired <
|
42
|
-
class PreconditionFailed <
|
43
|
-
class RequestEntityTooLarge <
|
44
|
-
class RequestURITooLong <
|
45
|
-
class UnsupportedMediaType <
|
46
|
-
class RequestedRangeNotSatisfiable <
|
47
|
-
class ExpectationFailed <
|
48
|
-
class UnprocessableEntity <
|
49
|
-
class InternalServerError <
|
50
|
-
class NotImplemented <
|
51
|
-
class BadGateway <
|
52
|
-
class ServiceUnavailable <
|
53
|
-
class GatewayTimeout <
|
25
|
+
class Continue < HTTPStatusError; end # 100
|
26
|
+
class SwitchingProtocols < HTTPStatusError; end # 101
|
27
|
+
class OK < HTTPStatusError; end # 200
|
28
|
+
class Created < HTTPStatusError; end # 201
|
29
|
+
class Accepted < HTTPStatusError; end # 202
|
30
|
+
class NonAuthoritativeInformation < HTTPStatusError; end # 203
|
31
|
+
class NoContent < HTTPStatusError; end # 204
|
32
|
+
class ResetContent < HTTPStatusError; end # 205
|
33
|
+
class PartialContent < HTTPStatusError; end # 206
|
34
|
+
class MultipleChoices < HTTPStatusError; end # 300
|
35
|
+
class MovedPermanently < HTTPStatusError; end # 301
|
36
|
+
class Found < HTTPStatusError; end # 302
|
37
|
+
class SeeOther < HTTPStatusError; end # 303
|
38
|
+
class NotModified < HTTPStatusError; end # 304
|
39
|
+
class UseProxy < HTTPStatusError; end # 305
|
40
|
+
class TemporaryRedirect < HTTPStatusError; end # 307
|
41
|
+
class BadRequest < HTTPStatusError; end # 400
|
42
|
+
class Unauthorized < HTTPStatusError; end # 401
|
43
|
+
class PaymentRequired < HTTPStatusError; end # 402
|
44
|
+
class Forbidden < HTTPStatusError; end # 403
|
45
|
+
class NotFound < HTTPStatusError; end # 404
|
46
|
+
class MethodNotAllowed < HTTPStatusError; end # 405
|
47
|
+
class NotAcceptable < HTTPStatusError; end # 406
|
48
|
+
class ProxyAuthenticationRequired < HTTPStatusError; end # 407
|
49
|
+
class RequestTimeout < HTTPStatusError; end # 408
|
50
|
+
class Conflict < HTTPStatusError; end # 409
|
51
|
+
class Gone < HTTPStatusError; end # 410
|
52
|
+
class LengthRequired < HTTPStatusError; end # 411
|
53
|
+
class PreconditionFailed < HTTPStatusError; end # 412
|
54
|
+
class RequestEntityTooLarge < HTTPStatusError; end # 412
|
55
|
+
class RequestURITooLong < HTTPStatusError; end # 414
|
56
|
+
class UnsupportedMediaType < HTTPStatusError; end # 415
|
57
|
+
class RequestedRangeNotSatisfiable < HTTPStatusError; end # 416
|
58
|
+
class ExpectationFailed < HTTPStatusError; end # 417
|
59
|
+
class UnprocessableEntity < HTTPStatusError; end # 422
|
60
|
+
class InternalServerError < HTTPStatusError; end # 500
|
61
|
+
class NotImplemented < HTTPStatusError; end # 501
|
62
|
+
class BadGateway < HTTPStatusError; end # 502
|
63
|
+
class ServiceUnavailable < HTTPStatusError; end # 503
|
64
|
+
class GatewayTimeout < HTTPStatusError; end # 504
|
54
65
|
|
55
66
|
# Messages for nicer exceptions, from rfc2616
|
56
67
|
def self.status_error(request, response)
|
@@ -96,7 +107,7 @@ module Excon
|
|
96
107
|
503 => [Excon::Errors::ServiceUnavailable, 'Service Unavailable'],
|
97
108
|
504 => [Excon::Errors::GatewayTimeout, 'Gateway Timeout']
|
98
109
|
}
|
99
|
-
error, message = @errors[response.status] || [Excon::Errors::
|
110
|
+
error, message = @errors[response.status] || [Excon::Errors::HTTPStatusError, 'Unknown']
|
100
111
|
error.new("Expected(#{request[:expects].inspect}) <=> Actual(#{response.status} #{message})\n request => #{request.inspect}\n response => #{response.inspect}", request, response)
|
101
112
|
end
|
102
113
|
|
data/lib/excon/response.rb
CHANGED
@@ -20,7 +20,7 @@ module Excon
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
unless params[:method] == 'HEAD'
|
23
|
+
unless params[:method].to_s.upcase == 'HEAD'
|
24
24
|
if !block || (params[:expects] && ![*params[:expects]].include?(response.status))
|
25
25
|
response.body = ''
|
26
26
|
block = lambda { |chunk| response.body << chunk }
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 7
|
9
|
+
version: 0.2.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- geemus (Wesley Beary)
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-30 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|