headers property

Map<String, String> headers
final

The HTTP headers returned by the server.

The header names are converted to lowercase and stored with their associated header values.

If the server returns multiple headers with the same name then the header values will be associated with a single key and seperated by commas and possibly whitespace. For example:

// HTTP/1.1 200 OK
// Fruit: Apple
// Fruit: Banana
// Fruit: Grape
final values = response.headers['fruit']!.split(RegExp(r'\s*,\s*'));
// values = ['Apple', 'Banana', 'Grape']

To retrieve the header values as a List<String>, use HeadersWithSplitValues.headersSplitValues.

If a header value contains whitespace then that whitespace may be replaced by a single space. Leading and trailing whitespace in header values are always removed.

Implementation

final Map<String, String> headers;