I have a use case where I am running the Karate Netty server as a forward proxy server to forward requests to a target Tomcat server. I noted that the hostname header gets set to the Karate Netty Server while forwarding the request which causes the request to not give a response. Can we somehow please update the request header before forwarding the request to target server.
Broader Use Case: Testing in live QA environment where we have a lift and shift project to move our rest services from one infrastructure platform to another infrastructure platform. Here is sample feature file:
Feature:
Scenario: pathMatches('/myresources/getResource') && methodIs('GET')
# Sending request to PLATFORM ABC URL
* karate.proceed('http://localhost:8081')
* def response1 = response
# Sending request to PLATFORM XYZ URL
* karate.proceed('http://localhost:8082')
* def response2 = response
* match response1 == response2
First, to your comment - getting the path including the query string is supposed to work via
requestUri
: https://github.com/karatelabs/karate/tree/master/karate-netty#requesturiBut we realized there's a bug. It will be fixed in the next version, but if you can validate from the
develop
branch, that will help us expedite a release.If you see the commits in issue #2295 linked above, you will see we introduced
requestPath
for more control over these cases.When it comes to headers, I think this line in your mock before you call
karate.proceed()
will do the trick:Do confirm. If you still see things that need to be tweaked, I request your help - you can see the flow and run this test to investigate. I remember someone ran into an issue with the content-length, so we decided to just remove that header in a mock, see this line.