mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.61k stars 1.08k forks source link

Invalid "content-encoding" value ".*" is automatically added to the request header #1473

Open ouchxp opened 2 years ago

ouchxp commented 2 years ago

Describe the issue When I send a POST request to the mock server, it proxy the request to my other service with an extra request header content-encoding: .* the target service fails because .* is not a valid encoding.

What you are trying to do Simply proxy a request to target service

MockServer version 5.14.0

To Reproduce Steps to reproduce the issue:

  1. How you are running MockServer (i.e maven plugin, docker, etc) docker with configs below
    environment:
      MOCKSERVER_LOG_LEVEL: DEBUG
      MOCKSERVER_SERVER_PORT: 1080
      PROXY_REMOTE_HOST: order
      PROXY_REMOTE_PORT: 3000
  2. Code you used to create expectations curl -v 'http://localhost:1080/orders' -X POST --data '{}'
  3. What error you saw Invalid content-encoding value added to the request header, target service fails

Expected behaviour Proxy requests should be exactly the same as the original requests

MockServer Log

order-service-mock                 | 2022-09-06 05:33:59 5.14.0 INFO 1080 received request:
order-service-mock                 |
order-service-mock                 |   {
order-service-mock                 |     "method" : "POST",
order-service-mock                 |     "path" : "/orders",
order-service-mock                 |     "headers" : {
order-service-mock                 |       "content-length" : [ "2" ],
order-service-mock                 |       "content-encoding" : [ ".*" ],
order-service-mock                 |       "User-Agent" : [ "curl/7.79.1" ],
order-service-mock                 |       "Host" : [ "localhost:1080" ],
order-service-mock                 |       "Content-Type" : [ "application/x-www-form-urlencoded" ],
order-service-mock                 |       "Accept" : [ "*/*" ]
order-service-mock                 |     },
order-service-mock                 |     "keepAlive" : true,
order-service-mock                 |     "secure" : false,
order-service-mock                 |     "localAddress" : "985a7e517c42/192.168.224.12:1080",
order-service-mock                 |     "remoteAddress" : "192.168.224.1",
order-service-mock                 |     "body" : "{}"
order-service-mock                 |   }
Agembin1 commented 1 year ago

Yes I am having this exact same issue.

My proxied POST calls return :

"faultstring": "Unsupported Encoding \".*\"",

the only work around is to add :

Content-Encoding: "" to the headers which seems to overwrite the bad value.

obviously this is not a workable solution for testing clients.

Please fix

ThaDaVos commented 1 year ago

This seems to be fixed in 5.15.0 - I checked the Changelog - and for me the header is no longer there