HttpHeaders class abstract interface

Headers for HTTP requests and responses.

In some situations, headers are immutable:

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.

Implementers

Properties

chunkedTransferEncoding bool
Whether the connection uses chunked transfer encoding.
getter/setter pair
contentLength int
The ContentType of the contentTypeHeader header, if any. The value of the contentLengthHeader header, if any.
getter/setter pair
date DateTime?
The date specified by the dateHeader header, if any.
getter/setter pair
expires DateTime?
The date and time specified by the expiresHeader header, if any.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
host String?
The value of the hostHeader header, if any.
getter/setter pair
ifModifiedSince DateTime?
The date and time specified by the ifModifiedSinceHeader header, if any.
getter/setter pair
persistentConnection bool
Whether the connection is persistent (keep-alive).
getter/setter pair
port int?
The value of the port part of the hostHeader header, if any.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(String name, Object value, {bool preserveHeaderCase = false}) → 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.
noFolding(String name) → void
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.
removeAll(String name) → void
Removes all values for the specified header name.
set(String name, Object value, {bool preserveHeaderCase = false}) → void
Sets the header name to value.
toString() String
A string representation of this object.
inherited
value(String name) String?
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

acceptCharsetHeader → const String
acceptEncodingHeader → const String
acceptHeader → const String
acceptLanguageHeader → const String
acceptRangesHeader → const String
accessControlAllowCredentialsHeader → const String
accessControlAllowHeadersHeader → const String
accessControlAllowMethodsHeader → const String
accessControlAllowOriginHeader → const String
accessControlExposeHeadersHeader → const String
accessControlMaxAgeHeader → const String
accessControlRequestHeadersHeader → const String
accessControlRequestMethodHeader → const String
ageHeader → const String
allowHeader → const String
authorizationHeader → const String
cacheControlHeader → const String
connectionHeader → const String
contentDisposition → const String
contentEncodingHeader → const String
contentLanguageHeader → const String
contentLengthHeader → const String
contentLocationHeader → const String
contentMD5Header → const String
contentRangeHeader → const String
contentTypeHeader → const String
cookieHeader → const String
dateHeader → const String
entityHeaders → const List<String>
etagHeader → const String
expectHeader → const String
expiresHeader → const String
fromHeader → const String
generalHeaders → const List<String>
hostHeader → const String
ifMatchHeader → const String
ifModifiedSinceHeader → const String
ifNoneMatchHeader → const String
ifRangeHeader → const String
ifUnmodifiedSinceHeader → const String
lastModifiedHeader → const String
locationHeader → const String
maxForwardsHeader → const String
pragmaHeader → const String
proxyAuthenticateHeader → const String
proxyAuthorizationHeader → const String
rangeHeader → const String
refererHeader → const String
requestHeaders → const List<String>
responseHeaders → const List<String>
retryAfterHeader → const String
serverHeader → const String
setCookieHeader → const String
teHeader → const String
trailerHeader → const String
transferEncodingHeader → const String
upgradeHeader → const String
userAgentHeader → const String
varyHeader → const String
viaHeader → const String
warningHeader → const String
wwwAuthenticateHeader → const String