HttpUrlConnection constructor

HttpUrlConnection(
  1. Url url
)

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.

Implementation

HttpUrlConnection(super.url);