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.acceptHeader, v);
request.headers.add(HttpHeaders.acceptHeader, "text/html"); To parse the header values use the parse static method.
HttpRequest request = ...;
List<String> values = request.headers[HttpHeaders.acceptHeader];
values.forEach((value) {
HeaderValue v = HeaderValue.parse(value);
// Use v.value and v.parameters
}); An instance of HeaderValue is immutable.
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-io/HeaderValue-class.html