New Fluxzy v2 just shipped. Electron is out, Tauri is in. gRPC ready, 3x smaller install. Learn more

updateResponseHeaderAction Action

Replace or add a response header on the fly, with `{{previous}}` support so you can append or prefix existing values cleanly.

Response headers shape how the browser caches, secures, and presents the page. Rewriting them in flight is one of the cleanest ways to test client behavior without rebuilding the backend, and {{previous}} keeps you safe from accidentally throwing away the original value.

When to use this action

Use updateResponseHeaderAction to change a header that the upstream server sent back, before Fluxzy hands the response to the client. The action overwrites the existing value or adds the header if addIfMissing is true. {{previous}} references the original value, which is useful when you want to prepend or append rather than replace.

Common situations:

  • Patch a missing or incorrect CORS header during local development.
  • Rewrite Cache-Control or Strict-Transport-Security to test how the client behaves under different security policies.
  • Override Server or X-Powered-By for fingerprint scrubbing during pentests.
  • Add a Content-Disposition to force a download in the browser.

Connection critical headers such as Transfer-Encoding, Content-Length, and Connection are filtered out, so the protocol stays consistent.

Real world examples

Force a permissive CORS header for local development

Insert Access-Control-Allow-Origin: * only when the upstream did not already return one, useful when running a local SPA against a remote API.

rules:
- filter:
    typeKind: HostFilter
    pattern: api.example.com
  actions:
  - typeKind: UpdateResponseHeaderAction
    headerName: Access-Control-Allow-Origin
    headerValue: "*"
    addIfMissing: true

Override Cache-Control on JSON responses

Make sure browsers never cache API responses while debugging, regardless of what the backend returns.

rules:
- filter:
    typeKind: JsonResponseFilter
  actions:
  - typeKind: UpdateResponseHeaderAction
    headerName: Cache-Control
    headerValue: no-store, no-cache, must-revalidate
    addIfMissing: true

Scrub the Server header in test reports

Replace the upstream server identification with a neutral value when sharing captures with third parties.

rules:
- filter:
    typeKind: AnyFilter
  actions:
  - typeKind: UpdateResponseHeaderAction
    headerName: Server
    headerValue: redacted
    addIfMissing: false

Reference

updateResponseHeaderAction

Description

Update and existing response header. If the header does not exists in the original response, the header will be added.
Use {{previous}} keyword to refer to the original value of the header.
Note Headers that alter the connection behaviour will be ignored.

Evaluation scope

Evaluation scope defines the timing where this filter will be applied.

responseHeaderReceivedFromRemote This scope occurs the moment fluxzy has done parsing the response header.

YAML configuration name

updateResponseHeaderAction

Settings

The following table describes the customizable properties available for this action:

Property Type Description DefaultValue
headerName string
headerValue string
addIfMissing boolean false

Example of usage

The following examples apply this action to any exchanges

Update the Server header.

rules:
- filter:
    typeKind: AnyFilter
  actions:
  - typeKind: UpdateResponseHeaderAction
    headerName: Server
    headerValue: Fluxzy

.NET reference

View definition of UpdateResponseHeaderAction for .NET integration.

See also

The following actions are related to this action:

Frequently asked questions

What does `{{previous}}` reference in this context?

The original value of the same header in the upstream response. If the header was absent, it expands to an empty string.

Will the client see the rewritten value?

Yes. The action runs on the responseHeaderReceivedFromRemote scope, which is before Fluxzy serializes the response back to the client.

Why is my Content-Length override ignored?

Connection and framing headers such as Content-Length, Transfer-Encoding, and Connection are protected. Use mockedResponseAction or content rewriting if you need to change the body.

Can I delete a header instead of updating it?

Use deleteResponseHeaderAction for that. updateResponseHeaderAction is dedicated to replacing or inserting a value, not removing one.

Learn more about Fluxzy rules