Dart API Referencedart:ioContentType

ContentType abstract class

Representation of a content type.

abstract class ContentType implements HeaderValue {
  /**
   * Creates a new content type object setting the primary type and
   * sub type.
   */
  factory ContentType([String primaryType = "", String subType = ""]) {
    return new _ContentType(primaryType, subType);
  }

  /**
   * Creates a new content type object from parsing a Content-Type
   * header value. As primary type, sub type and parameter names and
   * values are not case sensitive all these values will be converted
   * to lower case. Parsing this string
   *
   *     text/html; charset=utf-8
   *
   * will create a content type object with primary type [:text:], sub
   * type [:html:] and parameter [:charset:] with value [:utf-8:].
   */
  factory ContentType.fromString(String value) {
    return new _ContentType.fromString(value);
  }

  /**
   * Gets and sets the content type in the form "primaryType/subType".
   */
  String value;

  /**
   * Gets and sets the primary type.
   */
  String primaryType;

  /**
   * Gets and sets the sub type.
   */
  String subType;

  /**
   * Gets and sets the character set.
   */
  String charset;
}

Implements

HeaderValue

Constructors

factory ContentType([String primaryType = "", String subType = ""]) #

Creates a new content type object setting the primary type and sub type.

factory ContentType([String primaryType = "", String subType = ""]) {
  return new _ContentType(primaryType, subType);
}

factory ContentType.fromString(String value) #

Creates a new content type object from parsing a Content-Type header value. As primary type, sub type and parameter names and values are not case sensitive all these values will be converted to lower case. Parsing this string

text/html; charset=utf-8

will create a content type object with primary type text, sub type html and parameter charset with value utf-8.

factory ContentType.fromString(String value) {
  return new _ContentType.fromString(value);
}

Properties

String charset #

Gets and sets the character set.

String charset;

final Map<String, String> parameters #

inherited from HeaderValue

Gets the map of parameters.

Map<String, String> get parameters;

String primaryType #

Gets and sets the primary type.

String primaryType;

String subType #

Gets and sets the sub type.

String subType;

String value #

Gets and sets the content type in the form "primaryType/subType".

String value;

Methods

String toString() #

inherited from HeaderValue

Returns the formatted string representation in the form:

value; parameter1=value1; parameter2=value2
String toString();