Skip to content

Use port number from URL, if present #131

@kohenkatz

Description

@kohenkatz

The NIOHTTPClient takes the host URL, and also an optional port number as arguments.

However, the URL is also able to have a port number in it, for example: https://server.example.com:8080.

It is important for anyone who is already using the port argument to continue to be able to set it, but if it isn't explicitly set, we should use the port number from the URL, if present.

Currently, the initializer sets the port like this:

self.port = port ?? (useSSL ? 443 : 80)

Checking if the host URL has a port should be able to be done like this:

self.port = port ?? baseURL.port ?? (useSSL ? 443 : 80)

This uses:

  1. The explicit port number, if present
  2. The port number from the URL, if present
  3. The default port (80 or 443)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions