Add 'header value containing' matcher & header-value match-and-replace transform#249
Draft
komen205 wants to merge 3 commits into
Draft
Add 'header value containing' matcher & header-value match-and-replace transform#249komen205 wants to merge 3 commits into
komen205 wants to merge 3 commits into
Conversation
The existing 'with headers including' matcher requires the entire header value to match exactly, which makes it impossible to match one cookie within a multi-cookie Cookie header. This adds a new matcher that checks whether a given header's value contains a given substring, built on Mockttp's callback matcher so it needs no server-side changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replaces the UI-side callback-based matcher with the proper pattern: a real 'header-includes' matcher implemented in mockttp itself, evaluated server-side like all other matchers. This removes the need for the UI to stay connected for matching, and the per-request round-trip. Uses a locally-built mockttp 4.4.2 until that change is released. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds a third option to the headers transform dropdown: 'Match & replace text in a header value', configuring mockttp's new matchReplaceHeaders transform. This rewrites patterns within a header's value (e.g. one cookie's value inside a multi-cookie Cookie header) without replacing the whole header. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
Summary
Adds substring-level header matching and a header-value match-and-replace transform, so rules can target part of a header value instead of requiring the whole value to match exactly. The motivating case is a multi-cookie
Cookieheader, where today you can't match (or rewrite) a single cookie without touching the rest.This is the UI side of the change. It pairs with the Mockttp
header-includesmatcher /matchReplaceHeaderstransform (see the corresponding httptoolkit-server PR, which currently points at a locally-built mockttp 4.4.2 until that release ships).What's new
Cookieheader.header-includesmatcher in Mockttp itself, so it's evaluated server-side like every other matcher. This removes the per-request round-trip and the need for the UI to stay connected for matching to work.matchReplaceHeaders) without replacing the whole header. Handy for rewriting one cookie's value inside a combinedCookieheader.Notes
package.jsonis pinned to a local mockttp 4.4.2 build.Tests
test/unit/model/header-includes-matcher.spec.tstest/unit/model/transform-serialization.spec.ts