StreamedRequest class

An HTTP request where the request body is sent asynchronously after the connection has been established and the headers have been sent.

When the request is sent via BaseClient.send, only the headers and whatever data has already been written to StreamedRequest.sink will be sent immediately. More data will be sent as soon as it's written to StreamedRequest.sink, and when the sink is closed the request will end.

For example:

final request = http.StreamedRequest('POST', Uri.http('', ''))
    ..contentLength = 10
    ..sink.add([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

// The sink must be closed to end the request.
// The Future returned from `close()` may not complete until after the
// request is sent, and it should not be awaited.
final response = await request.send();


StreamedRequest(String method, Uri url)
Creates a new streaming request.


contentLength int?
The size of the request body, in bytes.
getter/setter pairinherited
finalized bool
Whether finalize has been called.
no setterinherited
followRedirects bool
Whether the client should follow redirects while resolving this request.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
maxRedirects int
The maximum number of redirects to follow when followRedirects is true.
getter/setter pairinherited
method String
The HTTP method of the request.
persistentConnection bool
Whether a persistent connection should be maintained with the server.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sink StreamSink<List<int>>
The sink to which to write data that will be sent as the request body.
no setter
url Uri
The URL to which the request will be sent.


finalize() ByteStream
Freezes all mutable fields and returns a single-subscription ByteStream that emits the data being written to sink.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
send() Future<StreamedResponse>
Sends this request.
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.