HeaderValue Interface
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();
v.value = "text/plain";
v.parameters["q"] = "0.3"
request.headers.add(HttpHeaders.ACCEPT, v);
request.headers.add(HttpHeaders.ACCEPT, "text/html");
To parse the header values use the fromString
constructor.
HttpRequest request = ...;
List<String> values = request.headers[HttpHeaders.ACCEPT];
values.forEach((value) {
HeaderValue v = new HeaderValue.fromString(value);
// Use v.value and v.parameters
});
Subinterfaces
Constructors
Code new HeaderValue.fromString(String value) #
Creates a new header value object from parsing a header value string with both value and optional parameters.
HeaderValue.fromString(String value);
Code new HeaderValue([String value]) #
Creates a new header value object setting the value part.
HeaderValue([String value]);
Methods
Code Map<String, String> get parameters() #
Gets the map of parameters.
Map<String, String> get parameters();
Code String toString() #
Returns the formatted string representation in the form:
value; parameter1=value1; parameter2=value2
String toString();