HttpBody class
Representation of an HTTP request body or an HTTP response body.
Body is available in three different formats:
- bytes (
Uint8List
) - text (
String
) - JSON (
Map
orList
) - assuming the content-type is JSON
Constructors
-
HttpBody.fromBytes(MediaType? contentType, List<
int> ? bytes, {Encoding? encoding, Encoding? fallbackEncoding}) - Construct the body to an HTTP request or an HTTP response from bytes.
- HttpBody.fromString(MediaType? contentType, String? body, {Encoding? encoding, Encoding? fallbackEncoding})
- Construct the body to an HTTP request or an HTTP response from text.
Properties
- contentLength → int
-
The size of this request/response body in bytes.
no setter
- contentType → MediaType?
-
The content type of this request/response. Includes the mime-type and
parameters such as charset.
final
- encoding → Encoding
-
Encoding used to encode/decode this request/response body.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asBytes(
) → Uint8List - Returns this request/response body as a list of bytes.
-
asJson(
) → dynamic -
Returns this request/response body as a JSON object - either a
Map
or aList
. -
asString(
) → String - Returns this request/response body as a String.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited