HttpUrlConnection class

A concrete implementation of UrlConnection for HTTP and HTTPS protocols.

This class uses Dart's HttpClient to establish a connection to the specified Url, sends the HTTP request, and retrieves the response.

Example:

final connection = HttpUrlConnection(Url.parse('https://example.com'));
await connection.connect();

final stream = connection.getInputStream();
int byte;
while ((byte = await stream.readByte()) != -1) {
  print(String.fromCharCode(byte));
}
await stream.close();

Errors during the connection process are wrapped in NetworkException for consistent handling.

Inheritance

Constructors

HttpUrlConnection(Url url)
A concrete implementation of UrlConnection for HTTP and HTTPS protocols.

Properties

hashCode int
The hash code for this object.
no setterinherited
request HttpClientRequest?
Returns the underlying HttpClientRequest object.
no setterinherited
response HttpClientResponse?
Returns the underlying HttpClientResponse object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url Url
The Url this connection was created for.
finalinherited

Methods

connect() Future<void>
Establishes a connection to the resource referenced by this UrlConnection.
override
getInputStream() InputStream
Returns an InputStream that reads the response body of this connection.
inherited
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