pact-foundation / pact-specification

Describes the pact format and verification specifications
MIT License
296 stars 28 forks source link

HTTP header behaviour in test cases differs from that in spec #51

Open richard-reece opened 6 years ago

richard-reece commented 6 years ago

The JVM test case asserts various aspects of HTTP header behaviour that is not mentioned in the spec, which says "Exact string match for expected header names and values." This makes it more difficult (frustrating) to implement a verifier. Two behaviours exist in the test cases:

For future implementors of the spec, please add a clarification to the header that replaces "Exact string match for expected header names and values." with words more accurately reflecting what an implementation should do.

How full an implementation of HTTP header value parsing should be implemented in order to allow comparison?

uglyog commented 6 years ago

In general, we should refer to the HTTP spec to define the rules. The pact spec is clearly wrong.

uglyog commented 6 years ago

@bethesque @mefellows we need to update the spec here, and make it consistent. I've looked at the JVM header matching code, and I don't think it is correct:

  1. Compare header keys case insensitive
  2. Compare header contents base on: 2.1 For cookie, split the value by semi-colon into a whitespace trimmed list, and the header matches if all the actual values contain the expected value at the same position 2.2 For content-type, split the value by semi-colon and trim white-space, then compare the first value:
    • if the first values differ, it is a mismatch
    • if the first values are the equal, and the tails are both empty, it is a match
    • otherwise, split the tails by = (stripping white-space) into a key-value map and compare case sensitive 2.3 otherwise strip any white-space after the commas in the values and compare case sensitive.

This looks wrong, but it has worked to date because 99% of header values don't have multiple values and don't use parameters.

bethesque commented 6 years ago

No worries, what should we change it to?