hoverfly icon indicating copy to clipboard operation
hoverfly copied to clipboard

Hoverfly ignores scheme when matching HTTP requests

Open veliakiner opened this issue 3 years ago • 1 comments

Description of the bug

When making HTTP requests via Hoverfly, it will ignore the scheme. I have a Python test which makes a request to "http://google.com" using the requests library, with Hoverfly set as the proxy. Before making the request, I load a JSON file containing one request-response pair, which has a scheme field set to https.

The response contains a custom Hoverfly-Cache-Served header which is absent from the response sent from google.com, allowing me to differentiate between a real and fake response.

Observed result

The response contains custom header, indicating that the request was matched (when it shouldn't).

Expected result

The response should not contain the custom header.

Additional relevant information

Hoverfly version: 1.3.1

Reproduced on OSX Mojave and Ubuntu 16 LTS.

I've set the scheme in the simulation to other things as well, and can confirm it's ignored each time.

Although the test cases uses the requests library, this is purely for easy reproduction. I originally saw this bug in a request made by Google Chrome, with Hoverfly set as an HTTP proxy.

I have a test case to reproduce the bug on the bug branch of https://github.com/kopernio/pytest-hoverfly-wrapper. To run, create a new Python virtual environment, run pip install -r requirements.txt, and ensure that the Hoverfly executable is in your PATH. Then run the test: pytest tests/test_hoverfly_wrapper.py::test_1

veliakiner avatar Jan 23 '21 14:01 veliakiner

duplicate i suppose https://github.com/SpectoLabs/hoverfly/issues/575

ns3777k avatar Jan 23 '21 15:01 ns3777k