webmock 3.26.2 → 3.26.4
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 +14 -0
- data/README.md +2 -0
- data/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +12 -1
- data/lib/webmock/http_lib_adapters/curb_adapter.rb +7 -1
- data/lib/webmock/http_lib_adapters/httpclient_adapter.rb +28 -1
- data/lib/webmock/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb0293b4433bbf3342d1f81abb5a1c773382f6f1a7fef6b44eb83fc0a38544a7
|
|
4
|
+
data.tar.gz: 00fbb149216fae39f04b689fc02c0f561e59e47843011fd8aaab36b35e86ba67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 664302057fd929d144d09bb739c0cc581f4b80b40b67093989a4df01a21337f12594b765d9da0bc980ba981cfbe8db451cf0d23ce4ed10fa5d57eb2ddd98de79
|
|
7
|
+
data.tar.gz: bad8a582bd3b717e11182aef243b7167021187d63bd40b2dc1f0f54f13928e898e45ecf1cb598419e8dfc643d5b270db0d3a5408ab871ffb0725d5560dbd556b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
# 3.26.4
|
|
4
|
+
|
|
5
|
+
* Fix race condition in `HTTPClient` adapter async requests by @koic in #1131
|
|
6
|
+
|
|
7
|
+
# 3.26.3
|
|
8
|
+
|
|
9
|
+
* Confirm to work with curb 1.3.7
|
|
10
|
+
|
|
11
|
+
Thanks to [Josch Bockler](https://github.com/jbockler)
|
|
12
|
+
|
|
13
|
+
* Fix NameError in async-http adapter on protocol-http1 >= 0.40
|
|
14
|
+
|
|
15
|
+
Thanks to [Leslie Hoare](https://github.com/lesleh)
|
|
16
|
+
|
|
3
17
|
# 3.26.2
|
|
4
18
|
|
|
5
19
|
* Add support to parse http/2 request on curb adapter
|
data/README.md
CHANGED
|
@@ -1213,6 +1213,8 @@ People who submitted patches and new features or suggested improvements. Many th
|
|
|
1213
1213
|
* Mikhail Doronin
|
|
1214
1214
|
* Christoph Rieß
|
|
1215
1215
|
* Erik Berlin
|
|
1216
|
+
* Josch Bockler
|
|
1217
|
+
* Leslie Hoare
|
|
1216
1218
|
|
|
1217
1219
|
For a full list of contributors you can visit the
|
|
1218
1220
|
[contributors](https://github.com/bblimke/webmock/contributors) page.
|
|
@@ -16,6 +16,17 @@ if defined?(Async::HTTP)
|
|
|
16
16
|
OriginalAsyncHttpClient = Async::HTTP::Client unless const_defined?(:OriginalAsyncHttpClient)
|
|
17
17
|
|
|
18
18
|
class << self
|
|
19
|
+
# protocol-http1 0.40.0 removed Protocol::HTTP1::Reason in favour of
|
|
20
|
+
# Protocol::HTTP::Status. Resolved on first use, rather than at load,
|
|
21
|
+
# so it does not depend on which of the two is required by then.
|
|
22
|
+
def status_descriptions
|
|
23
|
+
@status_descriptions ||= if defined?(::Protocol::HTTP1::Reason)
|
|
24
|
+
::Protocol::HTTP1::Reason::DESCRIPTIONS
|
|
25
|
+
else
|
|
26
|
+
::Protocol::HTTP::Status::DESCRIPTIONS
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
19
30
|
def enable!
|
|
20
31
|
Async::HTTP.send(:remove_const, :Client)
|
|
21
32
|
Async::HTTP.send(:const_set, :Client, Async::HTTP::WebMockClientWrapper)
|
|
@@ -112,7 +123,7 @@ if defined?(Async::HTTP)
|
|
|
112
123
|
webmock_response = WebMock::Response.new
|
|
113
124
|
webmock_response.status = [
|
|
114
125
|
response.status,
|
|
115
|
-
::
|
|
126
|
+
WebMock::HttpLibAdapters::AsyncHttpClientAdapter.status_descriptions[response.status]
|
|
116
127
|
]
|
|
117
128
|
webmock_response.headers = build_webmock_response_headers(response)
|
|
118
129
|
webmock_response.body = body
|
|
@@ -7,7 +7,13 @@ rescue LoadError
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
if defined?(Curl)
|
|
10
|
-
|
|
10
|
+
unsupported_curb_versions = ['0.8.7']
|
|
11
|
+
|
|
12
|
+
# Curl::Easy#perform raises "cannot define finalizer for TrueClass" on Ruby 2.6
|
|
13
|
+
# in curb 1.3.0 through 1.3.5. Fixed in curb 1.3.6. See https://github.com/taf2/curb/issues/478
|
|
14
|
+
unsupported_curb_versions += %w[1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5] if RUBY_VERSION < '2.7'
|
|
15
|
+
|
|
16
|
+
WebMock::VersionChecker.new('Curb', Curl::CURB_VERSION, '0.7.16', '1.3.7', unsupported_curb_versions).check_version!
|
|
11
17
|
|
|
12
18
|
module WebMock
|
|
13
19
|
module HttpLibAdapters
|
|
@@ -112,7 +112,10 @@ if defined?(::HTTPClient)
|
|
|
112
112
|
request_signature = build_request_signature(req)
|
|
113
113
|
webmock_request_signatures << request_signature
|
|
114
114
|
|
|
115
|
-
if webmock_responses[request_signature]
|
|
115
|
+
if webmock_responses[request_signature]
|
|
116
|
+
webmock_response = webmock_responses.delete(request_signature)
|
|
117
|
+
async_conn_for_stubbed_request(req, request_signature, webmock_response)
|
|
118
|
+
elsif WebMock.net_connect_allowed?(request_signature.uri)
|
|
116
119
|
conn = super
|
|
117
120
|
conn.async_thread[WEBMOCK_HTTPCLIENT_REQUEST_SIGNATURES] = Thread.current[WEBMOCK_HTTPCLIENT_REQUEST_SIGNATURES]
|
|
118
121
|
conn.async_thread[WEBMOCK_HTTPCLIENT_RESPONSES] = Thread.current[WEBMOCK_HTTPCLIENT_RESPONSES]
|
|
@@ -227,6 +230,30 @@ if defined?(::HTTPClient)
|
|
|
227
230
|
Thread.current[WEBMOCK_HTTPCLIENT_REQUEST_SIGNATURES] = nil
|
|
228
231
|
Thread.current[WEBMOCK_HTTPCLIENT_RESPONSES] = nil
|
|
229
232
|
end
|
|
233
|
+
|
|
234
|
+
# The async thread must not go through do_get, which would rebuild the request signature.
|
|
235
|
+
# Rebuilding calls headers_from_session again, and the session sets a Date header with
|
|
236
|
+
# 1 second resolution, so a signature built later can differ from the one the response was
|
|
237
|
+
# cached under, which makes the thread evaluate the stub registry again and consume
|
|
238
|
+
# an extra response from the stub sequence. The thread only delivers what the caller
|
|
239
|
+
# already evaluated, mirroring do_get's stubbed branch.
|
|
240
|
+
def async_conn_for_stubbed_request(req, request_signature, webmock_response)
|
|
241
|
+
conn = HTTPClient::Connection.new
|
|
242
|
+
conn.async_thread = Thread.new do
|
|
243
|
+
begin
|
|
244
|
+
WebMock::RequestRegistry.instance.requested_signatures.put(request_signature)
|
|
245
|
+
response = build_httpclient_response(webmock_response, true, req.header)
|
|
246
|
+
@request_filter.each do |filter|
|
|
247
|
+
filter.filter_response(req, response)
|
|
248
|
+
end
|
|
249
|
+
conn.push(response)
|
|
250
|
+
WebMock::CallbackRegistry.invoke_callbacks({lib: :httpclient}, request_signature, webmock_response)
|
|
251
|
+
rescue Exception => e
|
|
252
|
+
conn.push e
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
conn
|
|
256
|
+
end
|
|
230
257
|
end
|
|
231
258
|
|
|
232
259
|
class WebMockHTTPClient < HTTPClient
|
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.26.
|
|
4
|
+
version: 3.26.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bartosz Blimke
|
|
@@ -358,9 +358,9 @@ licenses:
|
|
|
358
358
|
- MIT
|
|
359
359
|
metadata:
|
|
360
360
|
bug_tracker_uri: https://github.com/bblimke/webmock/issues
|
|
361
|
-
changelog_uri: https://github.com/bblimke/webmock/blob/v3.26.
|
|
362
|
-
documentation_uri: https://www.rubydoc.info/gems/webmock/3.26.
|
|
363
|
-
source_code_uri: https://github.com/bblimke/webmock/tree/v3.26.
|
|
361
|
+
changelog_uri: https://github.com/bblimke/webmock/blob/v3.26.4/CHANGELOG.md
|
|
362
|
+
documentation_uri: https://www.rubydoc.info/gems/webmock/3.26.4
|
|
363
|
+
source_code_uri: https://github.com/bblimke/webmock/tree/v3.26.4
|
|
364
364
|
wiki_uri: https://github.com/bblimke/webmock/wiki
|
|
365
365
|
rdoc_options: []
|
|
366
366
|
require_paths:
|
|
@@ -376,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
376
376
|
- !ruby/object:Gem::Version
|
|
377
377
|
version: '0'
|
|
378
378
|
requirements: []
|
|
379
|
-
rubygems_version: 4.
|
|
379
|
+
rubygems_version: 4.0.16
|
|
380
380
|
specification_version: 4
|
|
381
381
|
summary: Library for stubbing HTTP requests in Ruby.
|
|
382
382
|
test_files: []
|