<#964 Multi-value headers are mishandled> Issue cr...
# pact-js-development
g
#964 Multi-value headers are mishandled Issue created by gruntster Software versions • OS: Ubuntu 22.04.1 LTS • Consumer Pact library: 10.1.4 • Node Version: 16.18.0 Issue Checklist Please confirm the following: ☑︎ I have upgraded to the latest ☑︎ I have the read the FAQs in the Readme ☑︎ I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures ☑︎ I have set my log level to debug and attached a log file showing the complete request/response cycle ☐ For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem Expected behaviour A multi-value header is matched against the multi-value header of the registered Interaction (v2). Substituting the Pact library with version 9.18.1 works as expected. Actual behaviour A multi-value header of the actual request appears to be processed as a single value that is a combination of all values. A multi-value header of the expected request is processed as the first value only.
Copy code
Mock server failed with the following mismatches:

        0) The following request was incorrect:

                GET /dogs

                         1.0 Mismatch with header 'dog-protocol': Expected 'woofruff' to be equal to 'woof'
Steps to reproduce package.json
Copy code
{
  "dependencies": {
    "@pact-foundation/pact": "10.1.4",
    "got": "11.8.5",
    "ts-node": "10.9.1"
  }
}
test.ts
Copy code
import { Interaction, Pact } from "@pact-foundation/pact";
import got from "got";
import * as path from "node:path";

async function test(): Promise<void> {
    const provider = new Pact({
        dir: path.resolve(process.cwd(), "pacts"),
        consumer: "MyConsumer",
        provider: "MyProvider",
        logLevel: "debug"
    });

    await provider.setup();

    await provider.addInteraction(
        new Interaction()
            .given("I have a list of dogs")
            .uponReceiving("a request for all dogs")
            .withRequest({
                method: "GET",
                path: "/dogs",
                headers: { "dog-protocol": "woof, ruff" }
            })
            .willRespondWith({ status: 200 }));

    try {
        await got.get(
            `${provider.mockService.baseUrl}/dogs`, {
                headers: { "dog-protocol": ["woof", "ruff"] },
                retry: 0
            });
    }
    catch (error) { }

    await provider.verify();
    await provider.finalize();
}

void test();
Steps 1.
npm i
2.
npx ts-node test.ts
Relevant log files test.txt pact-foundation/pact-js