byHeader method

MatchRules byHeader(
  1. String headerKey
)

Enforces that both requests have the same header with the given headerKey.

MatchRules rules = MatchRules().byHeader("Content-Type");

Implementation

MatchRules byHeader(String headerKey) {
  _by((Request received, Request recorded) {
    if (received.headers.containsKey(headerKey) &&
        recorded.headers.containsKey(headerKey)) {
      return received.headers[headerKey] == recorded.headers[headerKey];
    } else {
      return false;
    }
  });
  return this;
}