Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:io
  3. HeaderValue class
HeaderValue
description

HeaderValue classabstractinterface

Representation of a header value in the form:

value; parameter1=value1; parameter2=value2

HeaderValue can be used to conveniently build and parse headervalues on this form.

Parameter values can be omitted, in which case the value is parsed asnull.Values can be doubled quoted to allow characters outside of the RFC 7230token characters and backslash sequences can be used to represent the doublequote and backslash characters themselves.

To build an "accepts" header with the value

text/plain; q=0.3, text/html

use code like this:

HttpClientRequest request = ...;var v = 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 theparse 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 ofHeaderValue is immutable.

Implementers

Constructors

HeaderValue([Stringvalue ="",Map<String,String?>parameters =const {}])
Creates a new header value object setting the value and parameters.
factory

Properties

hashCodeint
The hash code for this object.
no setterinherited
parametersMap<String,String?>
A map of parameters.
no setter
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited
valueString
The value of the header.
no setter

Methods

noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString()String
Returns the formatted string representation in the form:
override

Operators

operator ==(Objectother)bool
The equality operator.
inherited

Static Methods

parse(Stringvalue, {StringparameterSeparator =";",String?valueSeparator,boolpreserveBackslash =false})HeaderValue
Creates a new header value object from parsing a header valuestring with both value and optional parameters.
  1. Dart
  2. dart:io
  3. HeaderValue class
dart:io library

[8]ページ先頭

©2009-2025 Movatter.jp