I'm using wiremock in standalone mode to proxy req...
# help
e
I'm using wiremock in standalone mode to proxy request to another server and to remove the Authorization header before sending the request to the other server. The proxy works well but the Authorization header is not remove. I start wiremock with this command line:
java -jar .\wiremock-standalone-3.13.0.jar --print-all-network-traffic
I have a json file in the mappings directory that configure the proxy and should remove Authorization header:
Copy code
{
  "request": {
    "method": "POST",
    "url": "/notification"
  },
  "response": {
    "proxyBaseUrl": "<http://localhost:8081>",
    "removeProxyRequestHeaders": [
      "Authorization"
    ]
  }
}
but at the end, the Authorization header is still sent to the final server did I miss anything?
l
Can't see anything off the top of my head. It all looks like it should work. I will try and replicate and see if I get the same issue
e
Thanks a lot
@Lee Turner I just succeed to remove the header after reading the source code of WireMock, I saw that method:
Copy code
public ProxyResponseDefinitionBuilder withRemoveRequestHeader(String key) {
      removeRequestHeaders.add(key.toLowerCase());
      return this;
    }
As there is a toLowerCase(), I change the header name in lower case in the json file:
Copy code
{
  "request": {
    "method": "POST",
    "url": "/notification"
  },
  "response": {
    "proxyBaseUrl": "<http://localhost:8081>",
    "removeProxyRequestHeaders": [
      "authorization"
    ]
  }
}
And it works!!!
Thank for your help
l
Ha, I didn't do anything, you did all the work 🙂
👍 1
It is a little confusing though and the example in the docs doesn't help. I will update the docs and maybe put a lowercase on the
removeProxyRequestHeaders
so users can add whatever case they want
e
Yes, perfect, thank you