Spec-Zone.ru › Dart 2

dart:io

HttpHeaders class

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.

Constructors

HttpHeaders()

Properties

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

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
inherited
Invoked when a non-existent method or property is accessed.
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
inherited
A string representation of this object.
value(String name) → String?
Convenience method for the value for a single valued header.

Operators

operator ==(Object other) → bool
inherited
The equality operator.
operator [](String name) → List<String>?
The values for the header named name.

Constants

acceptCharsetHeader → const String
"accept-charset"
acceptEncodingHeader → const String
"accept-encoding"
acceptHeader → const String
"accept"
acceptLanguageHeader → const String
"accept-language"
acceptRangesHeader → const String
"accept-ranges"
accessControlAllowCredentialsHeader → const String
'access-control-allow-credentials'
accessControlAllowHeadersHeader → const String
'access-control-allow-headers'
accessControlAllowMethodsHeader → const String
'access-control-allow-methods'
accessControlAllowOriginHeader → const String
'access-control-allow-origin'
accessControlExposeHeadersHeader → const String
'access-control-expose-headers'
accessControlMaxAgeHeader → const String
'access-control-max-age'
accessControlRequestHeadersHeader → const String
'access-control-request-headers'
accessControlRequestMethodHeader → const String
'access-control-request-method'
ageHeader → const String
"age"
allowHeader → const String
"allow"
authorizationHeader → const String
"authorization"
cacheControlHeader → const String
"cache-control"
connectionHeader → const String
"connection"
contentEncodingHeader → const String
"content-encoding"
contentLanguageHeader → const String
"content-language"
contentLengthHeader → const String
"content-length"
contentLocationHeader → const String
"content-location"
contentMD5Header → const String
"content-md5"
contentRangeHeader → const String
"content-range"
contentTypeHeader → const String
"content-type"
cookieHeader → const String
"cookie"
dateHeader → const String
"date"
entityHeaders → const List<String>
[allowHeader, contentEncodingHeader, contentLanguageHeader, contentLengthHeader, contentLocationHeader, contentMD5Header, contentRangeHeader, contentTypeHeader, expiresHeader, lastModifiedHeader]
etagHeader → const String
"etag"
expectHeader → const String
"expect"
expiresHeader → const String
"expires"
fromHeader → const String
"from"
generalHeaders → const List<String>
[cacheControlHeader, connectionHeader, dateHeader, pragmaHeader, trailerHeader, transferEncodingHeader, upgradeHeader, viaHeader, warningHeader]
hostHeader → const String
"host"
ifMatchHeader → const String
"if-match"
ifModifiedSinceHeader → const String
"if-modified-since"
ifNoneMatchHeader → const String
"if-none-match"
ifRangeHeader → const String
"if-range"
ifUnmodifiedSinceHeader → const String
"if-unmodified-since"
lastModifiedHeader → const String
"last-modified"
locationHeader → const String
"location"
maxForwardsHeader → const String
"max-forwards"
pragmaHeader → const String
"pragma"
proxyAuthenticateHeader → const String
"proxy-authenticate"
proxyAuthorizationHeader → const String
"proxy-authorization"
rangeHeader → const String
"range"
refererHeader → const String
"referer"
requestHeaders → const List<String>
[acceptHeader, acceptCharsetHeader, acceptEncodingHeader, acceptLanguageHeader, authorizationHeader, expectHeader, fromHeader, hostHeader, ifMatchHeader, ifModifiedSinceHeader, ifNoneMatchHeader, ifRa…
responseHeaders → const List<String>
[acceptRangesHeader, ageHeader, etagHeader, locationHeader, proxyAuthenticateHeader, retryAfterHeader, serverHeader, varyHeader, wwwAuthenticateHeader]
retryAfterHeader → const String
"retry-after"
serverHeader → const String
"server"
setCookieHeader → const String
"set-cookie"
teHeader → const String
"te"
trailerHeader → const String
"trailer"
transferEncodingHeader → const String
"transfer-encoding"
upgradeHeader → const String
"upgrade"
userAgentHeader → const String
"user-agent"
varyHeader → const String
"vary"
viaHeader → const String
"via"
warningHeader → const String
"warning"
wwwAuthenticateHeader → const String
"www-authenticate"

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.19.6/dart-io/HttpHeaders-class.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API