openConnection method

UrlConnection openConnection()

Opens a new UrlConnection to the resource represented by this Url.

The actual implementation depends on the scheme:

Throws a NetworkException if the protocol is unsupported.

Implementation

UrlConnection openConnection() {
  switch (protocol) {
    case 'http':
    case 'https':
      return HttpUrlConnection(this);
    default:
      throw NetworkException('Unsupported protocol: $protocol');
  }
}