HttpHeaders class - dart:io library (original) (raw)

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.

Properties

chunkedTransferEncodingbool

Whether the connection uses chunked transfer encoding.

getter/setter pair

contentLengthint

The value of the contentLengthHeader header, if any.

getter/setter pair

contentTypeContentType?

The ContentType of the contentTypeHeader header, if any.

getter/setter pair

dateDateTime?

The date specified by the dateHeader header, if any.

getter/setter pair

expiresDateTime?

The date and time specified by the expiresHeader header, if any.

getter/setter pair

hashCodeint

The hash code for this object.

no setterinherited

hostString?

The value of the hostHeader header, if any.

getter/setter pair

ifModifiedSinceDateTime?

The date and time specified by the ifModifiedSinceHeader header, if any.

getter/setter pair

persistentConnectionbool

Whether the connection is persistent (keep-alive).

getter/setter pair

portint?

The value of the port part of the hostHeader header, if any.

getter/setter pair

runtimeTypeType

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.

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, {})→ 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

contentDisposition → const String

contentEncodingHeader → const String

contentLanguageHeader → const String

contentLengthHeader → const String

contentLocationHeader → const String

contentMD5Header → const String

contentRangeHeader → const String

contentTypeHeader → const String