Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy - changing User-Agent with additionalProxyRequestHeaders stopped working after 3.2.0 #2690

Open
pfonseca-trip opened this issue Apr 19, 2024 · 1 comment
Labels

Comments

@pfonseca-trip
Copy link

Proposal

I'm using an API where part of its functionality depends on the User-Agent. To make it work with WireMock proxy I need to rewrite the User-Agent header using additionalProxyRequestHeaders, for example:

"response" : { "proxyBaseUrl": "https://one.api.com", "additionalProxyRequestHeaders": { "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_2 like Mac OS X)" } }

This stopped working after version 3.2.0.

Reproduction steps

  1. With WireMock >= 3.3.0
  2. Route a request through WireMock proxy
  3. Rewrite the User-Agent header with additionalProxyRequestHeaders

Expected result:
The host is sent the header defined in additionalProxyRequestHeaders

Actual result:
The host is sent the default WireMock user agent

References

https://wiremock.org/docs/proxying/#additional-headers

@kyle-winkelman
Copy link
Contributor

Can you try remove-headers to clear the existing value (I believe this requires 3.5+):

{
  "proxyBaseUrl": "https://one.api.com",
  "removeProxyRequestHeaders": [
      "User-Agent"
  ],
  "additionalProxyRequestHeaders": {
    "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_2 like Mac OS X)"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants