Skip to content

[BUG] Scripting: onRequest return drops Content-Encoding header with custom value #2579

@y-shih

Description

@y-shih

Environment

  • Proxyman Version: 6.3.0
  • macOS Version: 26.2 (25C56)
  • Script Type: Scripting Tool

Problem

When onRequest returns the request object (even without any modification to headers), Proxyman drops the Content-Encoding header from the actual HTTP request sent to the server.

Our server uses a custom Content-Encoding value (not gzip/deflate/br) to indicate a proprietary body encoding. After enabling Scripting, this header disappears.

Steps to Reproduce

  1. Create a Scripting rule matching any URL
  2. Use the following minimal script:
function onRequest(context, url, request) {
    console.log("INPUT Content-Encoding:", request.headers["Content-Encoding"]);
    request.customPreviewerTabs = { "Test": JSON.stringify({ ok: true }) };
    console.log("OUTPUT Content-Encoding:", request.headers["Content-Encoding"]);
    return request;
}
  1. Send a request that originally contains Content-Encoding: my_custom_value
  2. Observe:
    • Console shows both INPUT and OUTPUT have Content-Encoding: my_custom_value
    • But the actual Request Headers in Proxyman UI (and sent to server) do NOT contain Content-Encoding

Expected Behavior

Returning request from onRequest should preserve all original headers, including Content-Encoding with custom values.

Actual Behavior

Content-Encoding header is dropped after onRequest returns, even though:

  • It exists in request.headers when received
  • It still exists in request.headers when returned
  • The script does NOT modify request.headers

Evidence (Console Log)

[REQ] INPUT headers: Host, Content-Type, Connection, Accept, Content-Encoding, ...
[REQ] INPUT Content-Encoding: my_custom_value
[REQ] OUTPUT headers: Host, Content-Type, Connection, Accept, Content-Encoding, ...
[REQ] OUTPUT Content-Encoding: my_custom_value

But the actual HTTP request sent to server has no Content-Encoding header.

Impact

Server cannot detect the custom encoding and returns parse error.

Workaround Attempted

  • Copying headers with spread operator {...request, headers: {...request.headers}} — same result
  • Explicitly re-setting request.headers["Content-Encoding"] = originalValue — same result

None of these preserve the header in the actual outgoing request.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working✅ DoneTicket is addressed and fixed.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions