HttpHeaders class - dart:io library (original) (raw)
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.cacheControlHeader,
'max-age=3600, must-revalidate');
To retrieve the value of a header use the value()
method:
print(request.headers.value(HttpHeaders.userAgentHeader));
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.
Properties
chunkedTransferEncoding ↔ bool
Whether the connection uses chunked transfer encoding.
getter/setter pair
The value of the contentLengthHeader header, if any.
getter/setter pair
The ContentType of the contentTypeHeader header, if any.
getter/setter pair
The date specified by the dateHeader header, if any.
getter/setter pair
The date and time specified by the expiresHeader header, if any.
getter/setter pair
The hash code for this object.
no setterinherited
The value of the hostHeader header, if any.
getter/setter pair
The date and time specified by the ifModifiedSinceHeader header, if any.
getter/setter pair
Whether the connection is persistent (keep-alive).
getter/setter pair
The value of the port part of the hostHeader header, if any.
getter/setter pair
A representation of the runtime type of the object.
no setterinherited
Methods
add(String name, Object value, {})→ void
Adds a header value.
clear()→ void
Removes all headers.
forEach(void action(String name, List<String> values))→ void
Performs the action
on each header.
Disables folding for the header named name
when sending the HTTP header.
noSuchMethod(Invocation invocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String name, Object value)→ void
Removes a specific value for a header name.
Removes all values for the specified header name.
set(String name, Object value, {})→ void
Sets the header name
to value
.
A string representation of this object.
inherited
Convenience method for the value for a single valued header.
Operators
operator ==(Object other)→ bool
The equality operator.
inherited
operator [](String name)→ List<String>?
The values for the header named name
.
Constants
contentDisposition → const String
contentEncodingHeader → const String
contentLanguageHeader → const String
contentLengthHeader → const String
contentLocationHeader → const String
contentMD5Header → const String
contentRangeHeader → const String
contentTypeHeader → const String