webmock 3.39.0 → 3.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +16 -1
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +227 -27
- data/lib/webmock/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aa061376d2227028da9e7ca34091d2ec9b5afb3208f740fe5c7d981a903427d3
|
|
4
|
+
data.tar.gz: 8699e49411631af8a7d21312b23fdc98799cc0066be20c1df1ad7e8286a626b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f8690d37653f8c4719c827dc5a761c30f00d8419240eef5bbad8284dca046bccae7978b4cc9b4094d8122bf5c0d4169be75c9a4c35442516fdd5ff99974d4e61
|
|
7
|
+
data.tar.gz: '0583f069649719f6eff6cb01addb0a640ecbe4014ce94e1319699cd8cdc977b1b8367f2a7127c2f109714388adc99c85c522ca63d8cbb99ad92398ff389e859a'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# 3.40.0
|
|
4
|
+
|
|
5
|
+
* Add support for `Curl::Multi` (#535)
|
|
6
|
+
|
|
7
|
+
Previously, WebMock didn't see requests sent with `Curl::Multi`. A handle added with `multi.add` and sent with `multi.perform` went to the real server, even when a stub matched it or real connections were disabled, and WebMock didn't record it.
|
|
8
|
+
|
|
9
|
+
Now a handle that matches a stub gets the stubbed response during `multi.perform`, and one that is neither stubbed nor allowed raises `WebMock::NetConnectNotAllowedError` from `multi.add`. Allowed requests still run together in curb's own multi loop. WebMock records both, and `WebMock.after_request` callbacks get both.
|
|
10
|
+
|
|
11
|
+
If your tests send `Curl::Multi` requests to real servers, stub them or allow their hosts, for example with `WebMock.disable_net_connect!(allow: "api.example.com")`. VCR, hooked into WebMock, now records and replays these requests too, and raises `VCR::Errors::UnhandledHTTPRequestError` for one that a cassette doesn't have, so record such cassettes again.
|
|
12
|
+
|
|
13
|
+
Thanks to [Todd Fisher](https://github.com/taf2)
|
|
14
|
+
|
|
15
|
+
* Drop curb callbacks on `Curl::Easy#reset` for stubbed requests, as curb does
|
|
16
|
+
|
|
17
|
+
Previously, a callback such as `on_complete`, set before `reset`, still ran for a stubbed request made after it. Curb drops every callback on `reset`, so a real request didn't run it. If your tests rely on such a callback, set it again after `reset`.
|
|
18
|
+
|
|
3
19
|
# 3.39.0
|
|
4
20
|
|
|
5
21
|
* Fix tracing libraries that wrap HTTPClient failing on stubbed requests (#1010)
|
data/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Supported HTTP libraries
|
|
|
23
23
|
------------------------
|
|
24
24
|
|
|
25
25
|
* [Async::HTTP::Client](https://github.com/socketry/async-http)
|
|
26
|
-
* [Curb](https://github.com/taf2/curb) (`Curl::Easy`
|
|
26
|
+
* [Curb](https://github.com/taf2/curb) (`Curl::Easy` and `Curl::Multi`)
|
|
27
27
|
* [EM-HTTP-Request](https://github.com/igrigorik/em-http-request)
|
|
28
28
|
* [Excon](https://github.com/excon/excon)
|
|
29
29
|
* [HTTPClient](https://github.com/nahi/httpclient)
|
|
@@ -570,6 +570,20 @@ stub_request(:any, 'www.example.net').to_timeout
|
|
|
570
570
|
RestClient.post('www.example.net', 'abc') # ===> RestClient::RequestTimeout
|
|
571
571
|
```
|
|
572
572
|
|
|
573
|
+
### Curb multi requests
|
|
574
|
+
|
|
575
|
+
`Curl::Multi` matches each handle against stubs when it is added. An unstubbed
|
|
576
|
+
handle raises `WebMock::NetConnectNotAllowedError` from `multi.add` unless its
|
|
577
|
+
URL is allowed by WebMock's network settings. Stubbed handles complete when
|
|
578
|
+
`multi.perform` runs; allowed handles still run together on curb's native multi
|
|
579
|
+
loop. Both kinds of requests are recorded and invoke callbacks, including
|
|
580
|
+
`WebMock.after_request`. Callbacks registered with `real_requests_only: true`
|
|
581
|
+
receive only real transfers.
|
|
582
|
+
|
|
583
|
+
This also applies to `Curl::Multi.get`, `post`, `put` and `http`, and the `Curl.get`
|
|
584
|
+
and `Curl.post` convenience methods. Create the multi and easy handles after
|
|
585
|
+
WebMock is enabled, as with `Curl::Easy` requests.
|
|
586
|
+
|
|
573
587
|
### Multiple responses for repeated requests
|
|
574
588
|
|
|
575
589
|
```ruby
|
|
@@ -1487,6 +1501,7 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
|
1487
1501
|
* Hamza Tarar
|
|
1488
1502
|
* John Gallagher
|
|
1489
1503
|
* Yegor Bugayenko
|
|
1504
|
+
* Todd Fisher
|
|
1490
1505
|
|
|
1491
1506
|
For a full list of contributors you can visit the
|
|
1492
1507
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
|
@@ -22,14 +22,20 @@ if defined?(Curl)
|
|
|
22
22
|
|
|
23
23
|
OriginalCurlEasy = Curl::Easy unless const_defined?(:OriginalCurlEasy)
|
|
24
24
|
|
|
25
|
+
OriginalCurlMulti = Curl::Multi unless const_defined?(:OriginalCurlMulti)
|
|
26
|
+
|
|
25
27
|
def self.enable!
|
|
26
28
|
Curl.send(:remove_const, :Easy)
|
|
27
29
|
Curl.send(:const_set, :Easy, Curl::WebMockCurlEasy)
|
|
30
|
+
Curl.send(:remove_const, :Multi)
|
|
31
|
+
Curl.send(:const_set, :Multi, Curl::WebMockCurlMulti)
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def self.disable!
|
|
31
35
|
Curl.send(:remove_const, :Easy)
|
|
32
36
|
Curl.send(:const_set, :Easy, OriginalCurlEasy)
|
|
37
|
+
Curl.send(:remove_const, :Multi)
|
|
38
|
+
Curl.send(:const_set, :Multi, OriginalCurlMulti)
|
|
33
39
|
end
|
|
34
40
|
|
|
35
41
|
# Borrowed from Patron:
|
|
@@ -61,6 +67,82 @@ if defined?(Curl)
|
|
|
61
67
|
end
|
|
62
68
|
|
|
63
69
|
module Curl
|
|
70
|
+
class WebMockCurlMulti < Curl::Multi
|
|
71
|
+
# Intercept the native attachment boundary, retaining curb's public add,
|
|
72
|
+
# remove, request table and native event loop for allowed transfers.
|
|
73
|
+
def _add(easy)
|
|
74
|
+
# A handle of curb's own Curl::Easy class, such as a subclass defined
|
|
75
|
+
# before WebMock was loaded, one made while WebMock was disabled or a
|
|
76
|
+
# copy made with Curl::Easy#dup, makes its request without WebMock, as
|
|
77
|
+
# it always has. Easy#perform runs such handles through a multi too.
|
|
78
|
+
return super if !easy.is_a?(WebMockCurlEasy) || easy.webmock_performing_easy?
|
|
79
|
+
|
|
80
|
+
begin
|
|
81
|
+
signature, response = easy.webmock_request
|
|
82
|
+
rescue Exception # NetConnectNotAllowedError inherits directly from Exception.
|
|
83
|
+
# Older curb versions insert into requests before calling _add.
|
|
84
|
+
requests.delete(easy.object_id)
|
|
85
|
+
easy.webmock_restore_multi_url
|
|
86
|
+
raise
|
|
87
|
+
end
|
|
88
|
+
if response
|
|
89
|
+
easy.multi = self
|
|
90
|
+
webmock_pending[easy.object_id] = [easy, signature, response]
|
|
91
|
+
else
|
|
92
|
+
easy.webmock_record_multi_request(signature)
|
|
93
|
+
super
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def _remove(easy)
|
|
98
|
+
if webmock_pending.delete(easy.object_id)
|
|
99
|
+
easy.multi = nil
|
|
100
|
+
return self
|
|
101
|
+
end
|
|
102
|
+
super
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def perform(&block)
|
|
106
|
+
complete_webmock_requests
|
|
107
|
+
super do |multi|
|
|
108
|
+
begin
|
|
109
|
+
complete_webmock_requests
|
|
110
|
+
block.call(multi) if block
|
|
111
|
+
end until webmock_pending.empty?
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
def webmock_pending
|
|
118
|
+
@webmock_pending ||= {}
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def complete_webmock_requests
|
|
122
|
+
until webmock_pending.empty?
|
|
123
|
+
easy, signature, response = webmock_pending.values.first
|
|
124
|
+
# Curb 1.5 takes a handle out of the multi on reset or close without
|
|
125
|
+
# calling _remove, so it no longer belongs to this multi.
|
|
126
|
+
attached = requests.key?(easy.object_id)
|
|
127
|
+
# Detach before callbacks so they can remove or requeue handles.
|
|
128
|
+
remove(easy)
|
|
129
|
+
webmock_pending.delete(easy.object_id)
|
|
130
|
+
next unless attached
|
|
131
|
+
|
|
132
|
+
if easy.webmock_follow_multi_redirect(signature, response)
|
|
133
|
+
add(easy)
|
|
134
|
+
else
|
|
135
|
+
begin
|
|
136
|
+
easy.multi = self
|
|
137
|
+
easy.webmock_complete_multi_request(signature, response)
|
|
138
|
+
ensure
|
|
139
|
+
easy.multi = nil if easy.multi == self && !requests.key?(easy.object_id)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
64
146
|
class WebMockCurlEasy < Curl::Easy
|
|
65
147
|
# Curb's native PostField cannot be duplicated. Its public attributes
|
|
66
148
|
# describe the field without running a content callback or opening a file.
|
|
@@ -81,7 +163,10 @@ if defined?(Curl)
|
|
|
81
163
|
end
|
|
82
164
|
private_constant :MultipartField
|
|
83
165
|
|
|
84
|
-
def
|
|
166
|
+
def webmock_request
|
|
167
|
+
@webmock_method ||= :get
|
|
168
|
+
clear_webmock_response
|
|
169
|
+
webmock_clear_multi_request
|
|
85
170
|
request_signature = build_request_signature
|
|
86
171
|
recorded = signature_for_history(request_signature)
|
|
87
172
|
if request_signature.method == :put && @put_data.respond_to?(:read)
|
|
@@ -90,13 +175,22 @@ if defined?(Curl)
|
|
|
90
175
|
|
|
91
176
|
webmock_response = WebMock::StubRegistry.instance.response_for_request(
|
|
92
177
|
request_signature, record: recorded)
|
|
178
|
+
unless webmock_response || WebMock.net_connect_allowed?(request_signature.uri)
|
|
179
|
+
raise WebMock::NetConnectNotAllowedError.new(request_signature)
|
|
180
|
+
end
|
|
181
|
+
[request_signature, webmock_response]
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def curb_or_webmock
|
|
185
|
+
request_signature, webmock_response = webmock_request
|
|
93
186
|
if webmock_response
|
|
94
187
|
build_curb_response(webmock_response)
|
|
95
188
|
WebMock::CallbackRegistry.invoke_callbacks(
|
|
96
189
|
{lib: :curb}, request_signature, webmock_response)
|
|
97
190
|
invoke_curb_callbacks
|
|
98
191
|
true
|
|
99
|
-
|
|
192
|
+
else
|
|
193
|
+
@webmock_performing_easy = true
|
|
100
194
|
res = yield
|
|
101
195
|
if WebMock::CallbackRegistry.any_callbacks?
|
|
102
196
|
webmock_response = build_webmock_response
|
|
@@ -105,9 +199,104 @@ if defined?(Curl)
|
|
|
105
199
|
webmock_response)
|
|
106
200
|
end
|
|
107
201
|
res
|
|
202
|
+
end
|
|
203
|
+
ensure
|
|
204
|
+
@webmock_performing_easy = false
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def webmock_performing_easy?
|
|
208
|
+
@webmock_performing_easy
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def webmock_record_multi_request(signature)
|
|
212
|
+
@webmock_multi_request = signature
|
|
213
|
+
on_complete(&@on_complete)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def webmock_clear_multi_request
|
|
217
|
+
@webmock_multi_request = nil
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
%w[body header].each do |part|
|
|
221
|
+
define_method("on_#{part}") do |&block|
|
|
222
|
+
instance_variable_set("@on_#{part}", block)
|
|
223
|
+
if block
|
|
224
|
+
super() do |data|
|
|
225
|
+
if @webmock_multi_request
|
|
226
|
+
buffer = instance_variable_get("@webmock_#{part}") || +""
|
|
227
|
+
buffer << data
|
|
228
|
+
instance_variable_set("@webmock_#{part}", buffer)
|
|
229
|
+
end
|
|
230
|
+
block.call(data)
|
|
231
|
+
end
|
|
232
|
+
else
|
|
233
|
+
super(&block)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def on_complete(&block)
|
|
239
|
+
@on_complete = block
|
|
240
|
+
super do |easy|
|
|
241
|
+
signature = @webmock_multi_request
|
|
242
|
+
webmock_restore_multi_url
|
|
243
|
+
webmock_clear_multi_request
|
|
244
|
+
if signature && WebMock::CallbackRegistry.any_callbacks?
|
|
245
|
+
WebMock::CallbackRegistry.invoke_callbacks(
|
|
246
|
+
{lib: :curb, real_request: true}, signature, build_webmock_response)
|
|
247
|
+
end
|
|
248
|
+
block.call(easy) if block
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def webmock_follow_multi_redirect(signature, response)
|
|
253
|
+
location = response.headers && response.headers['Location']
|
|
254
|
+
return false unless follow_location? && (300..399).include?(response.status[0]) && location
|
|
255
|
+
return false if response.should_timeout || response.exception
|
|
256
|
+
|
|
257
|
+
@webmock_multi_redirects ||= 0
|
|
258
|
+
limit = max_redirects || 50
|
|
259
|
+
if limit >= 0 && @webmock_multi_redirects >= limit
|
|
260
|
+
@webmock_last_result = 47 # CURLE_TOO_MANY_REDIRECTS
|
|
261
|
+
return false
|
|
262
|
+
end
|
|
263
|
+
WebMock::CallbackRegistry.invoke_callbacks({lib: :curb}, signature, response)
|
|
264
|
+
@webmock_multi_original_url ||= url
|
|
265
|
+
@webmock_multi_redirects += 1
|
|
266
|
+
self.url = WebMock::Util::URI.heuristic_parse(url).join(location).to_s
|
|
267
|
+
true
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def webmock_restore_multi_url
|
|
271
|
+
return unless @webmock_multi_original_url
|
|
272
|
+
@last_effective_url = last_effective_url
|
|
273
|
+
self.url = @webmock_multi_original_url
|
|
274
|
+
@webmock_multi_original_url = @webmock_multi_redirects = nil
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def webmock_complete_multi_request(signature, response)
|
|
278
|
+
if response.should_timeout
|
|
279
|
+
@body_str = ""
|
|
280
|
+
@header_str = ""
|
|
281
|
+
@response_code = 0
|
|
282
|
+
@webmock_last_result = 28 # CURLE_OPERATION_TIMEDOUT
|
|
108
283
|
else
|
|
109
|
-
|
|
284
|
+
build_curb_response(response, follow_redirects: false)
|
|
285
|
+
@webmock_last_result ||= 0
|
|
110
286
|
end
|
|
287
|
+
webmock_restore_multi_url
|
|
288
|
+
WebMock::CallbackRegistry.invoke_callbacks({lib: :curb}, signature, response)
|
|
289
|
+
invoke_curb_callbacks(multi: true)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
def last_result
|
|
293
|
+
@webmock_last_result || super
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def clear_webmock_response
|
|
297
|
+
@body_str = @header_str = @response_code = @content_type = nil
|
|
298
|
+
@last_effective_url = @transfer_encoding = @webmock_last_result = nil
|
|
299
|
+
@webmock_body = @webmock_header = nil
|
|
111
300
|
end
|
|
112
301
|
|
|
113
302
|
def signature_for_history(signature)
|
|
@@ -138,7 +327,7 @@ if defined?(Curl)
|
|
|
138
327
|
nil
|
|
139
328
|
end
|
|
140
329
|
|
|
141
|
-
if
|
|
330
|
+
if @on_debug
|
|
142
331
|
@on_debug.call("Trying 127.0.0.1...\r\n", 0)
|
|
143
332
|
@on_debug.call('Connected to ' + uri.hostname + "\r\n", 0)
|
|
144
333
|
@debug_method = method.upcase
|
|
@@ -188,7 +377,7 @@ if defined?(Curl)
|
|
|
188
377
|
end
|
|
189
378
|
end
|
|
190
379
|
|
|
191
|
-
def build_curb_response(webmock_response)
|
|
380
|
+
def build_curb_response(webmock_response, follow_redirects: true)
|
|
192
381
|
raise Curl::Err::TimeoutError if webmock_response.should_timeout
|
|
193
382
|
webmock_response.raise_error_if_any
|
|
194
383
|
|
|
@@ -197,7 +386,7 @@ if defined?(Curl)
|
|
|
197
386
|
|
|
198
387
|
@header_str = "HTTP/1.1 #{webmock_response.status[0]} #{webmock_response.status[1]}\r\n".dup
|
|
199
388
|
|
|
200
|
-
@on_debug.call(@header_str, 1) if
|
|
389
|
+
@on_debug.call(@header_str, 1) if @on_debug
|
|
201
390
|
|
|
202
391
|
if webmock_response.headers
|
|
203
392
|
# Each cookie gets a line of its own, as servers send them.
|
|
@@ -205,14 +394,14 @@ if defined?(Curl)
|
|
|
205
394
|
values = k == "Set-Cookie" ? Array(v) : [v.is_a?(Array) ? v.join(", ") : v]
|
|
206
395
|
values.map do |value|
|
|
207
396
|
header = "#{k}: #{value}"
|
|
208
|
-
@on_debug.call(header + "\r\n", 1) if
|
|
397
|
+
@on_debug.call(header + "\r\n", 1) if @on_debug
|
|
209
398
|
header
|
|
210
399
|
end
|
|
211
400
|
end.join("\r\n")
|
|
212
|
-
@on_debug.call("\r\n", 1) if
|
|
401
|
+
@on_debug.call("\r\n", 1) if @on_debug
|
|
213
402
|
|
|
214
403
|
location = webmock_response.headers['Location']
|
|
215
|
-
if self.follow_location? && location
|
|
404
|
+
if follow_redirects && self.follow_location? && location
|
|
216
405
|
@last_effective_url = location
|
|
217
406
|
webmock_follow_location(location)
|
|
218
407
|
end
|
|
@@ -235,10 +424,10 @@ if defined?(Curl)
|
|
|
235
424
|
self.url = first_url
|
|
236
425
|
end
|
|
237
426
|
|
|
238
|
-
def invoke_curb_callbacks
|
|
239
|
-
@on_progress.call(0.0,1.0,0.0,1.0) if
|
|
240
|
-
self.header_str.lines.each { |header_line| @on_header.call header_line } if
|
|
241
|
-
if
|
|
427
|
+
def invoke_curb_callbacks(multi: false)
|
|
428
|
+
@on_progress.call(0.0,1.0,0.0,1.0) if @on_progress
|
|
429
|
+
self.header_str.lines.each { |header_line| @on_header.call header_line } if @on_header
|
|
430
|
+
if @on_body
|
|
242
431
|
if chunked_response?
|
|
243
432
|
self.body_str.each do |chunk|
|
|
244
433
|
@on_body.call(chunk)
|
|
@@ -247,15 +436,24 @@ if defined?(Curl)
|
|
|
247
436
|
@on_body.call(self.body_str)
|
|
248
437
|
end
|
|
249
438
|
end
|
|
250
|
-
|
|
439
|
+
completed_code = response_code
|
|
440
|
+
completed_result = last_result if multi
|
|
441
|
+
@on_complete.call(self) if @on_complete
|
|
442
|
+
|
|
443
|
+
if multi && completed_result != 0
|
|
444
|
+
@on_failure.call(self, Curl::Easy.error(completed_result)) if @on_failure
|
|
445
|
+
return
|
|
446
|
+
end
|
|
251
447
|
|
|
252
|
-
case
|
|
448
|
+
case completed_code
|
|
253
449
|
when 200..299
|
|
254
|
-
@on_success.call(self) if
|
|
450
|
+
@on_success.call(self) if @on_success
|
|
451
|
+
when 300..399
|
|
452
|
+
@on_redirect.call(self, Curl::Easy.error(0)) if multi && @on_redirect && max_redirects != 0
|
|
255
453
|
when 400..499
|
|
256
|
-
@on_missing.call(self, self.response_code) if
|
|
454
|
+
@on_missing.call(self, multi ? Curl::Easy.error(0) : self.response_code) if @on_missing
|
|
257
455
|
when 500..599
|
|
258
|
-
@on_failure.call(self, self.response_code) if
|
|
456
|
+
@on_failure.call(self, multi ? Curl::Easy.error(0) : self.response_code) if @on_failure
|
|
259
457
|
end
|
|
260
458
|
end
|
|
261
459
|
|
|
@@ -265,9 +463,9 @@ if defined?(Curl)
|
|
|
265
463
|
|
|
266
464
|
def build_webmock_response
|
|
267
465
|
status, headers =
|
|
268
|
-
WebMock::HttpLibAdapters::CurbAdapter.parse_header_string(self.header_str)
|
|
466
|
+
WebMock::HttpLibAdapters::CurbAdapter.parse_header_string((@webmock_header || self.header_str).to_s)
|
|
269
467
|
|
|
270
|
-
if
|
|
468
|
+
if @on_debug
|
|
271
469
|
http_response = ["HTTP/1.0 #{@debug_method} #{@debug_path}"]
|
|
272
470
|
headers.each do |name, value|
|
|
273
471
|
http_response << "#{name}: #{value}"
|
|
@@ -279,7 +477,7 @@ if defined?(Curl)
|
|
|
279
477
|
|
|
280
478
|
webmock_response = WebMock::Response.new
|
|
281
479
|
webmock_response.status = [self.response_code, status]
|
|
282
|
-
webmock_response.body = self.body_str
|
|
480
|
+
webmock_response.body = @webmock_body || self.body_str
|
|
283
481
|
webmock_response.headers = headers
|
|
284
482
|
webmock_response
|
|
285
483
|
end
|
|
@@ -395,7 +593,7 @@ if defined?(Curl)
|
|
|
395
593
|
@content_type ||= super
|
|
396
594
|
end
|
|
397
595
|
|
|
398
|
-
%w[ success failure missing
|
|
596
|
+
%w[ success failure missing redirect progress debug ].each do |callback|
|
|
399
597
|
class_eval <<-METHOD, __FILE__, __LINE__
|
|
400
598
|
def on_#{callback} &block
|
|
401
599
|
@on_#{callback} = block
|
|
@@ -410,12 +608,14 @@ if defined?(Curl)
|
|
|
410
608
|
|
|
411
609
|
def reset
|
|
412
610
|
@put_data = nil
|
|
611
|
+
clear_webmock_response
|
|
612
|
+
webmock_clear_multi_request
|
|
413
613
|
reset_webmock_method
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
614
|
+
@webmock_multi_original_url = @webmock_multi_redirects = nil
|
|
615
|
+
# Curb's reset drops every callback, so a stubbed request, or a real one
|
|
616
|
+
# WebMock records, doesn't run the ones set before it either.
|
|
617
|
+
@on_success = @on_failure = @on_missing = @on_redirect = @on_complete = nil
|
|
618
|
+
@on_body = @on_header = @on_progress = @on_debug = nil
|
|
419
619
|
super
|
|
420
620
|
end
|
|
421
621
|
end
|
data/lib/webmock/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: webmock
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.40.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bartosz Blimke
|
|
@@ -363,9 +363,9 @@ licenses:
|
|
|
363
363
|
- MIT
|
|
364
364
|
metadata:
|
|
365
365
|
bug_tracker_uri: https://github.com/bblimke/webmock/issues
|
|
366
|
-
changelog_uri: https://github.com/bblimke/webmock/blob/v3.
|
|
367
|
-
documentation_uri: https://www.rubydoc.info/gems/webmock/3.
|
|
368
|
-
source_code_uri: https://github.com/bblimke/webmock/tree/v3.
|
|
366
|
+
changelog_uri: https://github.com/bblimke/webmock/blob/v3.40.0/CHANGELOG.md
|
|
367
|
+
documentation_uri: https://www.rubydoc.info/gems/webmock/3.40.0
|
|
368
|
+
source_code_uri: https://github.com/bblimke/webmock/tree/v3.40.0
|
|
369
369
|
wiki_uri: https://github.com/bblimke/webmock/wiki
|
|
370
370
|
rdoc_options: []
|
|
371
371
|
require_paths:
|