Repository navigation
Update Rust crate httpmock to 0.9.0 - #316
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #316 +/- ##
=======================================
Coverage 79.34% 79.34%
=======================================
Files 13 13
Lines 2116 2116
=======================================
Hits 1679 1679
Misses 437 437 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fajinyuan
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.8.0→0.9.0Release Notes
httpmock/httpmock (httpmock)
v0.9.0Compare Source
The crate was upgraded to the Rust 2024 edition. The minimum supported Rust version
remains 1.88.
Breaking changes
server::matchersis now crate-private(#312). Its matcher, comparator and reader
types are implementation details rather than a supported extension API; there is no
replacement public path. Custom predicates remain possible with
When::is_true.is_blank,contains_str,contains_sliceandcontains_vecwere removed (#246). Use
request.body_string().contains(".."), which also works insiderespond_with, orrequest.body_ref().windows(n).any(|w| w == b"..")with a non-empty needle, andWhen::body_includeswhen matching.HttpMockRequest::query_params_map()was removed(#246). Collect
query_params()instead:let params: HashMap<String, String> = request.query_params().into_iter().collect();keeps the last value for duplicate keys, as the removed method did.
query_params()hasreturned
Vec<(String, String)>since 0.8.2.MockExttrait was removed andMock's publicidfield is now private(#285). Remove
MockExtimports andreplace direct
mock.idfield access withmock.id().Mock::new(id, &server)isunchanged.
send it) when the
http2cargo feature is enabled(#297). Previously this worked without the
feature. It fails at runtime, not at compile time: the client sees the connection closed
after the preface and the server logs "invalid HTTP version parsed (found HTTP2 preface)".
Enable
http2to keep serving such clients;standaloneand the Docker image alreadyinclude it. HTTPS via ALPN is unaffected, as
h2was already only offered with the featureenabled. The crate also no longer enables
tokio/signalorhyper/http2for other cratesin the build, so a crate that relied on that has to enable them itself.
server::state::MockServerStateandserver::state::HttpMockStateManagerare nowcrate-private (#289,
#326). Neither could be used from outside
the crate beyond constructing it; code using the
MockServerAPI is unaffected.experimentalCargo feature was removed(#316). Remove it from your dependency's
feature list; it did not enable any functionality.
(#202,
1231c63).
curlandwgetare nolonger installed, so healthchecks that call them need another probe: an
httpGetprobeagainst
/__httpmock__/ping, or from inside the containerbash -c 'exec 3<>/dev/tcp/127.0.0.1/5050'. The CA files are no longer in the image either;use
certs/ca.pemfrom the repository orserver::DEFAULT_CA_CERTIFICATE. The executableis now at
/usr/local/bin/httpmock, with a compatibility symlink at/usr/local/cargo/bin/httpmockso existing absolute paths continue to work.tls-detectcargo feature was removed(#333). It only enabled an internal
dependency that
httpsalready pulled in; remove it from your feature list.clap,colored,headers,hyper-rustls,if-addrs,rcgen,rustls,rustls-pki-types,serde_yaml,tokio-rustlsandtracing-subscriberare enabled through the documented features only.Replace any of these names in your feature list with the feature that needs them, such as
httpsorstandalone.RecordingRuleBuilder::configis now private(#322). Its type could only be used through
type inference; configure recordings through the builder's methods.
Upgrading from 0.8
Most code needs no changes. Remove
MockExtimports and usemock.id()to read a mock'sID. Replace
body().is_blank()withbody_string().trim().is_empty()andbody().contains_str("x")withbody_string().contains("x"). Replacequery_params_map()with
query_params().into_iter().collect::<HashMap<_, _>>().Direct imports from
server::matchersmust be removed; use theWhenAPI to configurematchers instead.
Tests whose clients speak cleartext HTTP/2 to the mock server additionally need the
http2feature.
The methods deprecated since 0.8.0 (
Mock::hits,hits_async,assert_hits,assert_hits_asyncandWhen::matches) are still available and will be removed in 1.0.Improvements
HttpMockResponse::to_http_response()for converting to an HTTP response with a byte body. The method borrows the response and
returns any conversion error.
calls with
Then::up_to_n_times,Mock::up_to_n_timesorMock::up_to_n_times_async,after which they stop matching requests. Static mock YAML files support the same limit as
up_to_n_timesunderthen.MockServer::reset(), whichstart()andconnect()call,now also resets the call counters of static YAML mocks. (resolves
#96)
(thanks @wfchandler)
Sendwhen theirinputs do, allowing registration inside
tokio::spawn(#325).
When,Thenand the forwarding, proxy and recording rule builders are nowSendandSync(#322).30% smaller (74 to 52 crates without default features, 86 to 64 with them), resolving
#46
async-traitandtls-detectare nolonger dependencies. The server now tells TLS and plain HTTP connections apart by the first
byte the client sends.
conversions avoid unnecessary body clones.
json_bodyandbody_from_file(resolves issues#118 and
#185)
exposed for testing as
server::DEFAULT_CA_CERTIFICATEandserver::DEFAULT_CA_PRIVATE_KEY(
httpsfeature) (thanks @ErikMcClure)introduced in v0.8.0 is now documented
Bug fixes
HttpMockServerBuilder::build()returns an error instead of panicking when the directoryof static mock files cannot be listed, and the YAML and file error messages were reworded
(904fc03)
deleted" and failed state operations "state operation failed: ...". Only clients that match
on the response body of a failed request can notice
http2feature now also enables HTTP/2 in the HTTPS client, soremote,httpsandhttp2compile together withoutremote-httpshttpsfeature builds correctlyagain (hyper-rustls/ring is enabled) (thanks @danieleades)
#326: Server TLS falls back to ring when no
rustls crypto provider is installed, instead of panicking when several providers are compiled
in (thanks @danieleades)
DELETE /recordings/:idnow deletesrecordings instead of proxy rules (thanks @danieleades)
history_limitishonored instead of a hardcoded cap (thanks @danieleades)
*_prefixand*_suffixmatchers no longer panic with a char-boundary error whenbuilding a mismatch report for a request value containing multi-byte UTF-8 characters
values containing tab characters (e.g. TSV bodies) verbatim instead of re-aligning them into
columns
Recording::saveandsave_tono longeroverwrite a recording saved under the same scenario name in the same second; the second file
gets a counter suffix
(
<scenario>_<timestamp>_1.yaml)Internal improvements and CI
[lints.rust]inCargo.tomldenies warnings, replacing the old#![allow(warnings)].Cargo caps lints for registry and git dependencies, but a path dependency on httpmock builds
with them on; use
--cap-lints warnthere if a newer compiler adds a warningMockServerStateremoval is listed under breaking changes) (thanks @danieleades)Dependency updates
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.