Search code examples
urilanguage-lawyeramqp

Does a URI always have a host part


Must a strictly valid URI that has an authority part (the kind you would use as a URL to access a remote resource) always have a host part?

That is, is the AMQP connection "URI" amqp://

  • a valid URI with an empty (zero length) host part
  • not really a valid URI because it lacks a host part

Solution

  • Yes, a valid URI always has a host part, although it may be zero-length.

    Quoth the standard:

    If the URI scheme defines a default for host, then that default applies when the host subcomponent is undefined or when the registered name is empty (zero length).

    The standard then notes that the default host for the file scheme is the local host, but that there is no default host for the http scheme, so the host part must be non-empty for that scheme.