excon 0.64.0 → 0.65.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.

Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/data/cacert.pem +108 -2
  3. data/excon.gemspec +7 -2
  4. data/lib/excon.rb +11 -11
  5. data/lib/excon/connection.rb +25 -25
  6. data/lib/excon/response.rb +1 -1
  7. data/lib/excon/version.rb +1 -1
  8. metadata +3 -101
  9. data/.document +0 -5
  10. data/.github/stale.yml +0 -17
  11. data/.gitignore +0 -13
  12. data/.rspec +0 -3
  13. data/.travis.yml +0 -17
  14. data/Gemfile +0 -19
  15. data/Rakefile +0 -41
  16. data/benchmarks/class_vs_lambda.rb +0 -50
  17. data/benchmarks/concat_vs_insert.rb +0 -21
  18. data/benchmarks/concat_vs_interpolate.rb +0 -22
  19. data/benchmarks/cr_lf.rb +0 -21
  20. data/benchmarks/downcase-eq-eq_vs_casecmp.rb +0 -169
  21. data/benchmarks/excon.rb +0 -69
  22. data/benchmarks/excon_vs.rb +0 -165
  23. data/benchmarks/for_vs_array_each.rb +0 -27
  24. data/benchmarks/for_vs_hash_each.rb +0 -27
  25. data/benchmarks/has_key-vs-lookup.rb +0 -177
  26. data/benchmarks/headers_case_sensitivity.rb +0 -83
  27. data/benchmarks/headers_split_vs_match.rb +0 -34
  28. data/benchmarks/implicit_block-vs-explicit_block.rb +0 -98
  29. data/benchmarks/merging.rb +0 -21
  30. data/benchmarks/single_vs_double_quotes.rb +0 -21
  31. data/benchmarks/string_ranged_index.rb +0 -87
  32. data/benchmarks/strip_newline.rb +0 -115
  33. data/benchmarks/vs_stdlib.rb +0 -82
  34. data/changelog.txt +0 -1113
  35. data/spec/excon/error_spec.rb +0 -139
  36. data/spec/excon/test/server_spec.rb +0 -28
  37. data/spec/excon_spec.rb +0 -7
  38. data/spec/helpers/file_path_helpers.rb +0 -22
  39. data/spec/helpers/warning_helpers.rb +0 -9
  40. data/spec/requests/basic_spec.rb +0 -40
  41. data/spec/requests/eof_requests_spec.rb +0 -36
  42. data/spec/requests/unix_socket_spec.rb +0 -38
  43. data/spec/requests/validation_spec.rb +0 -80
  44. data/spec/spec_helper.rb +0 -26
  45. data/spec/support/shared_contexts/test_server_context.rb +0 -83
  46. data/spec/support/shared_contexts/test_stub_context.rb +0 -11
  47. data/spec/support/shared_examples/shared_example_for_clients.rb +0 -220
  48. data/spec/support/shared_examples/shared_example_for_streaming_clients.rb +0 -20
  49. data/spec/support/shared_examples/shared_example_for_test_servers.rb +0 -16
  50. data/tests/authorization_header_tests.rb +0 -27
  51. data/tests/bad_tests.rb +0 -69
  52. data/tests/basic_tests.rb +0 -351
  53. data/tests/batch_requests.rb +0 -133
  54. data/tests/complete_responses.rb +0 -31
  55. data/tests/data/127.0.0.1.cert.crt +0 -17
  56. data/tests/data/127.0.0.1.cert.key +0 -28
  57. data/tests/data/excon.cert.crt +0 -17
  58. data/tests/data/excon.cert.key +0 -28
  59. data/tests/data/xs +0 -1
  60. data/tests/error_tests.rb +0 -145
  61. data/tests/header_tests.rb +0 -119
  62. data/tests/instrumentors/logging_instrumentor_tests.rb +0 -28
  63. data/tests/middleware_tests.rb +0 -27
  64. data/tests/middlewares/canned_response_tests.rb +0 -34
  65. data/tests/middlewares/capture_cookies_tests.rb +0 -34
  66. data/tests/middlewares/decompress_tests.rb +0 -157
  67. data/tests/middlewares/escape_path_tests.rb +0 -36
  68. data/tests/middlewares/idempotent_tests.rb +0 -245
  69. data/tests/middlewares/instrumentation_tests.rb +0 -315
  70. data/tests/middlewares/mock_tests.rb +0 -304
  71. data/tests/middlewares/redirect_follower_tests.rb +0 -112
  72. data/tests/pipeline_tests.rb +0 -40
  73. data/tests/proxy_tests.rb +0 -306
  74. data/tests/query_string_tests.rb +0 -87
  75. data/tests/rackups/basic.rb +0 -41
  76. data/tests/rackups/basic.ru +0 -3
  77. data/tests/rackups/basic_auth.ru +0 -14
  78. data/tests/rackups/deflater.ru +0 -4
  79. data/tests/rackups/proxy.ru +0 -18
  80. data/tests/rackups/query_string.ru +0 -13
  81. data/tests/rackups/redirecting.ru +0 -23
  82. data/tests/rackups/redirecting_with_cookie.ru +0 -40
  83. data/tests/rackups/request_headers.ru +0 -15
  84. data/tests/rackups/request_methods.ru +0 -21
  85. data/tests/rackups/response_header.ru +0 -18
  86. data/tests/rackups/ssl.ru +0 -16
  87. data/tests/rackups/ssl_mismatched_cn.ru +0 -15
  88. data/tests/rackups/ssl_verify_peer.ru +0 -16
  89. data/tests/rackups/streaming.ru +0 -30
  90. data/tests/rackups/thread_safety.ru +0 -17
  91. data/tests/rackups/timeout.ru +0 -14
  92. data/tests/rackups/webrick_patch.rb +0 -34
  93. data/tests/request_headers_tests.rb +0 -21
  94. data/tests/request_method_tests.rb +0 -47
  95. data/tests/request_tests.rb +0 -58
  96. data/tests/response_tests.rb +0 -197
  97. data/tests/servers/bad.rb +0 -25
  98. data/tests/servers/eof.rb +0 -17
  99. data/tests/servers/error.rb +0 -20
  100. data/tests/servers/good.rb +0 -342
  101. data/tests/servers/good_ipv4.rb +0 -8
  102. data/tests/servers/good_ipv6.rb +0 -8
  103. data/tests/test_helper.rb +0 -297
  104. data/tests/thread_safety_tests.rb +0 -39
  105. data/tests/timeout_tests.rb +0 -12
  106. data/tests/utils_tests.rb +0 -81
@@ -1,28 +0,0 @@
1
- require 'logger'
2
-
3
- Shindo.tests('logging instrumentor') do
4
- env_init
5
-
6
- tests("connection logger").returns(true) do
7
- Excon.stub({:method => :get}, {body: 'body', status: 200})
8
-
9
- log_path = "/tmp/excon_#{Time.now.to_i}.txt"
10
- logger = Logger.new(log_path)
11
- # omit datetime to simplify test matcher
12
- logger.formatter = proc do |severity, datetime, progname, msg|
13
- "#{msg}\n"
14
- end
15
-
16
- connection = Excon.new(
17
- 'http://127.0.0.1:9292',
18
- instrumentor: Excon::LoggingInstrumentor,
19
- logger: logger,
20
- mock: true
21
- )
22
- response = connection.request(method: :get, path: '/logger')
23
- File.readlines(log_path)[1..2] == [
24
- "request: http://127.0.0.1/logger\n",
25
- "response: body\n"
26
- ]
27
- end
28
- end
@@ -1,27 +0,0 @@
1
- Shindo.tests('Excon middleware') do
2
-
3
- with_rackup('basic.ru', '0.0.0.0') do
4
- tests('succeeds without defining valid_parameter_keys') do
5
- class Middleware
6
- def initialize(stack)
7
- @stack = stack
8
- end
9
- def error_call(datum)
10
- @stack.error_call(datum)
11
- end
12
- def request_call(datum)
13
- @stack.request_call(datum)
14
- end
15
- def response_call(datum)
16
- @stack.response_call(datum)
17
- end
18
- end
19
- silence_warnings do
20
- Excon.get(
21
- 'http://127.0.0.1:9292/content-length/100',
22
- :middlewares => Excon.defaults[:middlewares] + [Middleware]
23
- )
24
- end
25
- end
26
- end
27
- end
@@ -1,34 +0,0 @@
1
- Shindo.tests("Excon support for middlewares that return canned responses") do
2
- the_body = "canned"
3
-
4
- canned_response_middleware = Class.new(Excon::Middleware::Base) do
5
- define_method :request_call do |params|
6
- params[:response] = {
7
- :body => the_body,
8
- :headers => {},
9
- :status => 200
10
- }
11
- super(params)
12
- end
13
- end
14
-
15
- tests('does not mutate the canned response body').returns(the_body) do
16
- Excon.get(
17
- 'http://some-host.com/some-path',
18
- :middlewares => [canned_response_middleware] + Excon.defaults[:middlewares]
19
- ).body
20
- end
21
-
22
- tests('yields non-mutated body to response_block').returns(the_body) do
23
- body = ''
24
- response_block = lambda { |chunk, _, _| body << chunk }
25
- Excon.get(
26
- 'http://some-host.com/some-path',
27
- :middlewares => [canned_response_middleware] + Excon.defaults[:middlewares],
28
- :response_block => response_block
29
- )
30
- body
31
- end
32
-
33
- end
34
-
@@ -1,34 +0,0 @@
1
- Shindo.tests("Excon redirecting with cookie preserved") do
2
- env_init
3
-
4
- with_rackup('redirecting_with_cookie.ru') do
5
- tests('second request will send cookies set by the first').returns('ok') do
6
- Excon.get(
7
- 'http://127.0.0.1:9292',
8
- :path => '/sets_cookie',
9
- :middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower]
10
- ).body
11
- end
12
-
13
- tests('second request will send multiple cookies set by the first').returns('ok') do
14
- Excon.get(
15
- 'http://127.0.0.1:9292',
16
- :path => '/sets_multi_cookie',
17
- :middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower]
18
- ).body
19
- end
20
- end
21
-
22
- with_rackup('redirecting.ru') do
23
- tests("runs normally when there are no cookies set").returns('ok') do
24
- Excon.post(
25
- 'http://127.0.0.1:9292',
26
- :path => '/first',
27
- :middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::CaptureCookies, Excon::Middleware::RedirectFollower],
28
- :body => "a=Some_content"
29
- ).body
30
- end
31
- end
32
-
33
- env_restore
34
- end
@@ -1,157 +0,0 @@
1
- Shindo.tests('Excon Decompress Middleware') do
2
- env_init
3
-
4
- with_server('good_ipv4') do
5
-
6
- before do
7
- @connection ||= Excon.new(
8
- 'http://127.0.0.1:9292/echo/content-encoded',
9
- :method => :post,
10
- :body => 'hello world',
11
- :middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::Decompress]
12
- )
13
- end
14
-
15
- tests('gzip') do
16
- resp = nil
17
-
18
- tests('response body decompressed').returns('hello world') do
19
- resp = @connection.request(
20
- :headers => { 'Accept-Encoding' => 'gzip, deflate;q=0' }
21
- )
22
- resp[:body]
23
- end
24
-
25
- tests('server sent content-encoding').returns('gzip') do
26
- resp[:headers]['Content-Encoding-Sent']
27
- end
28
-
29
- tests('removes processed encoding from header').returns('') do
30
- resp[:headers]['Content-Encoding']
31
- end
32
-
33
- tests('empty response body').returns('') do
34
- resp = @connection.request(:body => '')
35
- resp[:body]
36
- end
37
- end
38
-
39
- tests('deflate') do
40
- resp = nil
41
-
42
- tests('response body decompressed').returns('hello world') do
43
- resp = @connection.request(
44
- :headers => { 'Accept-Encoding' => 'gzip;q=0, deflate' }
45
- )
46
- resp[:body]
47
- end
48
-
49
- tests('server sent content-encoding').returns('deflate') do
50
- resp[:headers]['Content-Encoding-Sent']
51
- end
52
-
53
- tests('removes processed encoding from header').returns('') do
54
- resp[:headers]['Content-Encoding']
55
- end
56
- end
57
-
58
- tests('with pre-encoding') do
59
- resp = nil
60
-
61
- tests('server sent content-encoding').returns('other, gzip') do
62
- resp = @connection.request(
63
- :headers => { 'Accept-Encoding' => 'gzip, deflate;q=0',
64
- 'Content-Encoding-Pre' => 'other' }
65
- )
66
- resp[:headers]['Content-Encoding-Sent']
67
- end
68
-
69
- tests('processed encoding removed from header').returns('other') do
70
- resp[:headers]['Content-Encoding']
71
- end
72
-
73
- tests('response body decompressed').returns('hello world') do
74
- resp[:body]
75
- end
76
-
77
- end
78
-
79
- tests('with post-encoding') do
80
- resp = nil
81
-
82
- tests('server sent content-encoding').returns('gzip, other') do
83
- resp = @connection.request(
84
- :headers => { 'Accept-Encoding' => 'gzip, deflate;q=0',
85
- 'Content-Encoding-Post' => 'other' }
86
- )
87
- resp[:headers]['Content-Encoding-Sent']
88
- end
89
-
90
- tests('unprocessed since last applied is unknown').returns('gzip, other') do
91
- resp[:headers]['Content-Encoding']
92
- end
93
-
94
- tests('response body still compressed').returns('hello world') do
95
- Zlib::GzipReader.new(StringIO.new(resp[:body])).read
96
- end
97
-
98
- end
99
-
100
- tests('with a :response_block') do
101
- captures = nil
102
- resp = nil
103
-
104
- tests('server sent content-encoding').returns('gzip') do
105
- captures = capture_response_block do |block|
106
- resp = @connection.request(
107
- :headers => { 'Accept-Encoding' => 'gzip'},
108
- :response_block => block
109
- )
110
- end
111
- resp[:headers]['Content-Encoding-Sent']
112
- end
113
-
114
- tests('unprocessed since :response_block was used').returns('gzip') do
115
- resp[:headers]['Content-Encoding']
116
- end
117
-
118
- tests(':response_block passed unprocessed data').returns('hello world') do
119
- body = captures.map {|capture| capture[0] }.join
120
- Zlib::GzipReader.new(StringIO.new(body)).read
121
- end
122
-
123
- end
124
-
125
- tests('adds Accept-Encoding if needed') do
126
-
127
- tests('without a :response_block').returns('deflate, gzip') do
128
- resp = Excon.post(
129
- 'http://127.0.0.1:9292/echo/request',
130
- :body => 'hello world',
131
- :middlewares => Excon.defaults[:middlewares] +
132
- [Excon::Middleware::Decompress]
133
- )
134
- request = Marshal.load(resp.body)
135
- request[:headers]['Accept-Encoding']
136
- end
137
-
138
- tests('with a :response_block').returns(nil) do
139
- captures = capture_response_block do |block|
140
- Excon.post(
141
- 'http://127.0.0.1:9292/echo/request',
142
- :body => 'hello world',
143
- :response_block => block,
144
- :middlewares => Excon.defaults[:middlewares] +
145
- [Excon::Middleware::Decompress]
146
- )
147
- end
148
- request = Marshal.load(captures.map {|capture| capture[0] }.join)
149
- request[:headers]['Accept-Encoding']
150
- end
151
-
152
- end
153
-
154
- end
155
-
156
- env_restore
157
- end
@@ -1,36 +0,0 @@
1
- Shindo.tests('Excon Decompress Middleware') do
2
- env_init
3
- with_rackup('basic.ru') do
4
- tests('encoded uri passed to connection') do
5
- tests('GET /echo%20dirty').returns(200) do
6
- connection = Excon::Connection.new({
7
- :host => '127.0.0.1',
8
- :hostname => '127.0.0.1',
9
- :middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::EscapePath],
10
- :nonblock => false,
11
- :port => 9292,
12
- :scheme => 'http',
13
- :ssl_verify_peer => false
14
- })
15
- response = connection.request(:method => :get, :path => '/echo%20dirty')
16
- response[:status]
17
- end
18
- end
19
-
20
- tests('unencoded uri passed to connection') do
21
- tests('GET /echo dirty').returns(200) do
22
- connection = Excon::Connection.new({
23
- :host => '127.0.0.1',
24
- :hostname => '127.0.0.1',
25
- :middlewares => Excon.defaults[:middlewares] + [Excon::Middleware::EscapePath],
26
- :nonblock => false,
27
- :port => 9292,
28
- :scheme => 'http',
29
- :ssl_verify_peer => false
30
- })
31
- response = connection.request(:method => :get, :path => '/echo dirty')
32
- response[:status]
33
- end
34
- end
35
- end
36
- end
@@ -1,245 +0,0 @@
1
- Shindo.tests('Excon request idempotencey') do
2
-
3
- before do
4
- @connection = Excon.new('http://127.0.0.1:9292', :mock => true)
5
- end
6
-
7
- after do
8
- # flush any existing stubs after each test
9
- Excon.stubs.clear
10
- end
11
-
12
- tests("Non-idempotent call with an erroring socket").raises(Excon::Error::Socket) do
13
- run_count = 0
14
- Excon.stub({:method => :get}) { |params|
15
- run_count += 1
16
- if run_count <= 3 # First 3 calls fail.
17
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
18
- else
19
- {:body => params[:body], :headers => params[:headers], :status => 200}
20
- end
21
- }
22
-
23
- @connection.request(:method => :get, :path => '/some-path')
24
- end
25
-
26
- tests("Idempotent request with socket erroring first 3 times").returns(200) do
27
- run_count = 0
28
- Excon.stub({:method => :get}) { |params|
29
- run_count += 1
30
- if run_count <= 3 # First 3 calls fail.
31
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
32
- else
33
- {:body => params[:body], :headers => params[:headers], :status => 200}
34
- end
35
- }
36
-
37
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path')
38
- response.status
39
- end
40
-
41
- tests("Idempotent request with socket erroring first 5 times").raises(Excon::Error::Socket) do
42
- run_count = 0
43
- Excon.stub({:method => :get}) { |params|
44
- run_count += 1
45
- if run_count <= 5 # First 5 calls fail.
46
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
47
- else
48
- {:body => params[:body], :headers => params[:headers], :status => 200}
49
- end
50
- }
51
-
52
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path')
53
- response.status
54
- end
55
-
56
- tests("Lowered retry limit with socket erroring first time").returns(200) do
57
- run_count = 0
58
- Excon.stub({:method => :get}) { |params|
59
- run_count += 1
60
- if run_count <= 1 # First call fails.
61
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
62
- else
63
- {:body => params[:body], :headers => params[:headers], :status => 200}
64
- end
65
- }
66
-
67
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 2)
68
- response.status
69
- end
70
-
71
- tests("Lowered retry limit with socket erroring first 3 times").raises(Excon::Error::Socket) do
72
- run_count = 0
73
- Excon.stub({:method => :get}) { |params|
74
- run_count += 1
75
- if run_count <= 3 # First 3 calls fail.
76
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
77
- else
78
- {:body => params[:body], :headers => params[:headers], :status => 200}
79
- end
80
- }
81
-
82
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 2)
83
- response.status
84
- end
85
-
86
- tests("Raised retry limit with socket erroring first 5 times").returns(200) do
87
- run_count = 0
88
- Excon.stub({:method => :get}) { |params|
89
- run_count += 1
90
- if run_count <= 5 # First 5 calls fail.
91
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
92
- else
93
- {:body => params[:body], :headers => params[:headers], :status => 200}
94
- end
95
- }
96
-
97
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 8)
98
- response.status
99
- end
100
-
101
- tests("Raised retry limit with socket erroring first 9 times").raises(Excon::Error::Socket) do
102
- run_count = 0
103
- Excon.stub({:method => :get}) { |params|
104
- run_count += 1
105
- if run_count <= 9 # First 9 calls fail.
106
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
107
- else
108
- {:body => params[:body], :headers => params[:headers], :status => 200}
109
- end
110
- }
111
-
112
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 8)
113
- response.status
114
- end
115
-
116
- tests("Retry limit in constructor with socket erroring first 5 times").returns(200) do
117
- run_count = 0
118
- Excon.stub({:method => :get}) { |params|
119
- run_count += 1
120
- if run_count <= 5 # First 5 calls fail.
121
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
122
- else
123
- {:body => params[:body], :headers => params[:headers], :status => 200}
124
- end
125
- }
126
-
127
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 6)
128
- response.status
129
- end
130
-
131
- tests("Retry limit and sleep in constructor with socket erroring first 2 times").returns(200) do
132
- run_count = 0
133
- Excon.stub({:method => :get}) { |params|
134
- run_count += 1
135
- if run_count <= 2 # First 5 calls fail.
136
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
137
- else
138
- {:body => params[:body], :headers => params[:headers], :status => 200}
139
- end
140
- }
141
-
142
-
143
- # NOTE: A short :retry_interval will avoid slowing down the tests.
144
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 3, :retry_interval => 0.1)
145
- response.status
146
- end
147
-
148
- tests("Retry limit and sleep in constructor with socket erroring first 2 times").raises(Excon::Error::Socket) do
149
- run_count = 0
150
- Excon.stub({:method => :get}) { |params|
151
- run_count += 1
152
- if run_count <= 2 # First 5 calls fail.
153
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
154
- else
155
- {:body => params[:body], :headers => params[:headers], :status => 200}
156
- end
157
- }
158
-
159
- # NOTE: A short :retry_interval will avoid slowing down the tests.
160
- response = @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :retry_limit => 2, :retry_interval => 0.1)
161
- response.status
162
- end
163
-
164
- tests("Idempotent request with custom error first 3 times").returns(200) do
165
- run_count = 0
166
- Excon.stub({:method => :get}) { |params|
167
- run_count += 1
168
- if run_count <= 3 # First 3 calls fail.
169
- raise "oops"
170
- else
171
- {:body => params[:body], :headers => params[:headers], :status => 200}
172
- end
173
- }
174
-
175
- response = @connection.request(:method => :get, :idempotent => true, :retry_errors => [RuntimeError], :path => '/some-path')
176
- response.status
177
- end
178
-
179
- tests("Idempotent request with custom error first 5 times").raises(RuntimeError) do
180
- run_count = 0
181
- Excon.stub({:method => :get}) { |params|
182
- run_count += 1
183
- if run_count <= 5 # First 5 calls fail.
184
- raise "oops"
185
- else
186
- {:body => params[:body], :headers => params[:headers], :status => 200}
187
- end
188
- }
189
-
190
- response = @connection.request(:method => :get, :idempotent => true, :retry_errors => [RuntimeError], :path => '/some-path')
191
- response.status
192
- end
193
-
194
- tests("Overriding default retry_errors").raises(Excon::Error::Socket) do
195
- Excon.stub({:method => :get}) { |params|
196
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
197
- }
198
-
199
- response = @connection.request(:method => :get, :idempotent => true, :retry_errors => [RuntimeError], :path => '/some-path')
200
- response.status
201
- end
202
-
203
- class Block
204
- attr_reader :rewound
205
- def initialize
206
- @rewound = false
207
- end
208
- def call(_)
209
- end
210
- def rewind
211
- @rewound = true
212
- end
213
- end
214
-
215
- tests("request_block rewound").returns(true) do
216
- run_count = 0
217
- Excon.stub({:method => :get}) { |params|
218
- run_count += 1
219
- if run_count <= 1 # First call fails.
220
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
221
- else
222
- {:body => params[:body], :headers => params[:headers], :status => 200}
223
- end
224
- }
225
- request_block = Block.new
226
- @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :request_block => request_block, :retry_limit => 2, :retry_interval => 0.1)
227
- request_block.rewound
228
- end
229
-
230
- tests("response_block rewound").returns(true) do
231
- run_count = 0
232
- Excon.stub({:method => :get}) { |params|
233
- run_count += 1
234
- if run_count <= 1 # First call fails.
235
- raise Excon::Error::Socket.new(Exception.new "Mock Error")
236
- else
237
- {:body => params[:body], :headers => params[:headers], :status => 200}
238
- end
239
- }
240
- response_block = Block.new
241
- @connection.request(:method => :get, :idempotent => true, :path => '/some-path', :response_block => response_block, :retry_limit => 2, :retry_interval => 0.1)
242
- response_block.rewound
243
- end
244
-
245
- end