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: ";", 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])
-
Creates a new header value object setting the value and parameters.
factory
Properties
Operators
-
operator ==(
other) → bool -
The equality operator.…
inherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
noSuchMethod is invoked when users invoke a non-existent method on an object. The name of the method and the arguments of the invocation are passed to noSuchMethod in an Invocation. If noSuchMethod returns a value, that value becomes the result of the original invocation.…
inherited -
toString(
) → String -
Returns the formatted string representation in the form:…