hasHeader function

Matcher hasHeader(
  1. String name, [
  2. Object? valueMatcher
])

Matches a response that has the specified header.

If valueMatcher is provided, also checks the header value.

Example:

expect(res, hasHeader('content-type'));
expect(res, hasHeader('content-type', 'application/json'));
expect(res, hasHeader('content-type', contains('json')));

Implementation

Matcher hasHeader(String name, [Object? valueMatcher]) =>
    _HeaderMatcher(name, valueMatcher);