Headers for HTTP requests and responses.
In some situations, headers are immutable:
HttpRequest and HttpClientResponse always have immutable headers.
HttpResponse and HttpClientRequest have immutable headers from the moment the body is written to.
In these situations, the mutating methods throw exceptions.
For all operations on HTTP headers the header name is case-insensitive.
To set the value of a header use the set()
method:
request.headers.set(HttpHeaders.CACHE_CONTROL,
'max-age=3600, must-revalidate');
To retrieve the value of a header use the value()
method:
print(request.headers.value(HttpHeaders.USER_AGENT));
An HttpHeaders object holds a list of values for each name
as the standard allows. In most cases a name holds only a single value,
The most common mode of operation is to use set()
for setting a value,
and value()
for retrieving a value.