Skip to content

Hoverfly replaces "Host" header in SPY mode #1013

Description

@gaa94

Description of the bug

I am using hoverfly-java (0.14.0) with my Spring project in integration testing.
My actual service (under test/spy) calls are routed through envoy which relies on the Host: X header - where X specifies the service name.
For example, this is the original request:

{
    "method" : "GET",
    "url" : "http://localhost:9211/sample-path/1",
    "queryStringParameters" : {},
    "headers" : {
      "Host" : [ "my-service.service" ],
      "Accept" : [ "application/json" ]
    }
  }

While using Hoverfly in SPY mode, it is proxying requests but replacing the Host header to finally have this request:

{
    "method" : "GET",
    "url" : "http://localhost:{hoverlfy-port}/sample-path/1",
    "queryStringParameters" : {},
    "headers" : {
      "Host" : [ "localhost:9211" ],
      "Accept" : [ "application/json" ]
    }
  }

This makes the underlying service unable to route requests.

Is it possible to specify custom header for Hoverfly to use internally for forwarding requests? Or can I explicitly re-set the header using a hack?

Steps to reproduce the issue

I can upload a sample project in the discussion below - however, the issue is easy to reproduce with SPY mode.

Observed result

404 Not Found due to wrong Host header

Expected result

200 OK

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions