HeaderValue abstract class
Representation of a header value in the form:
value; parameter1=value1; parameter2=value2
HeaderValue can be used to conveniently build and parse header values on this form.
To build an accepts
header with the value
text/plain; q=0.3, text/html
use code like this:
HttpClientRequest request = ...; var v = new HeaderValue("text/plain", {"q": "0.3"}); request.headers.add(HttpHeaders.ACCEPT, v); request.headers.add(HttpHeaders.ACCEPT, "text/html");
To parse the header values use the parse
static method.
HttpRequest request = ...; List<String> values = request.headers[HttpHeaders.ACCEPT]; values.forEach((value) { HeaderValue v = HeaderValue.parse(value); // Use v.value and v.parameters });
An instance of HeaderValue is immutable.
- Implemented by
Static Methods
- parse(
String value, { String parameterSeparator: ";", String valueSeparator: null, bool preserveBackslash: false }) → HeaderValue -
Creates a new header value object from parsing a header value string with both value and optional parameters.
Constructors
- HeaderValue([String value = "", Map<String, String> parameters ]) factory
-
Creates a new header value object setting the value and parameters.
Properties
- parameters → Map<String, String> read-only
-
Gets the map of parameters.
- value → String read-only
-
Gets the header value.
- hashCode → int read-only, inherited
-
The hash code for this object.
- runtimeType → Type read-only, inherited
-
A representation of the runtime type of the object.
Operators
- operator ==(
other) → bool inherited -
The equality operator.
Methods
- toString(
) → String -
Returns the formatted string representation in the form:
- noSuchMethod(
Invocation invocation) → dynamic inherited -
Invoked when a non-existent method or property is accessed.
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-io/HeaderValue-class.html