Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Functions uriParseAuthority

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module juptune.http.uri;

Result uriParseAuthority(
    const char[] chars, 
    const char[] userInfo, 
    const char[] host, 
    Nullable!(
        IpAddress
    ) hostAsIp, 
    Nullable!(
        ushort
    ) port, 
    const char[] next, 
    UriParseHints hints, 
    UriParseRules rules = UriParseRules.strict
);

Documentation

Parses the authority of a URI.

Valid Formats

isAbsolute when UriParseHints.isAbsoluteis set -> //authority/path?query#fragment, e.g. "//authority/some/path?some=query#some-fragment"

isNetworkReference when UriParseHints.isAbsoluteis not set -> //authority/path?query#fragment, e.g. "//authority/some/path?some=query#some-fragment"

isUriSuffix when UriParseHints.isAbsoluteis not set and when the input is not a network reference -> host/path?query#fragment, e.g. "localhost/some/path?some=query#some-fragment"

empty, yet successful result when none of the above can be determined, the entire input string is returned in nextand the function returns Result.noError. -> e.g. /some/absolute/path

percentEncodedUserInfo mixes with any of the above -> user%40info@host/path?query#fragment, e.g. "user%40info@localhost/some/path?some=query#some-fragment"

percentEncodedHost mixes with any of the above -> ho%20st/path?query#fragment, e.g. "ho%20st/some/path?some=query#some-fragment"

(The following hints are capable of being mixed and matched. Listing all permutations is not useful.)

authorityHasUserInfo -> user:info@host/path?query#fragment, e.g. "user:info@localhost/some/path?some=query#some-fragment"

authorityHasPort -> host:port/path?query#fragment, e.g. "localhost:8080/some/path?some=query#some-fragment"

authorityHostIsIpv6 -> [::1]/path?query#fragment, e.g. "[::1]/some/path?some=query#some-fragment"

authorityHostIsIpv4 -> 0.0.0.0/path?query#fragment, e.g. "127.0.0.1/some/path?some=query#some-fragment"

authorityHostIsDomain -> localhost/path?query#fragment, e.g. "localhost/some/path?some=query#some-fragment" -> abc.com/path?query#fragment, e.g. "abc.com/some/path?some=query#some-fragment" -> 0.0.0.0.abc.com/path?query#fragment, e.g. "127.0.0.1.domain/some/path?some=query#some-fragment"

Notes

Given the string "//user:info@localhost:8080/abc", the userInfoparameter will be set to "user:info", the hostparameter will be set to "localhost", the portparameter will be set to 8080, and the nextparameter will be set to "/abc".

The output of all outparameters is undefined if the function returns an error.

If the host is intended to be an IPv4 address, but is for some reason invalid, it will be interpreted as a domain name instead without an error being generated.

If the host is an IP address, then the hostAsIpparameter will be set to the parsed IP address. Additionally if there is a port, then the portfield within the IpAddressstruct will also be set.

While percent encoding is validated, it is not decoded.

Params

Throws

UriError.authorityRequiredif the URI is absolute (has a scheme), but has no authority component.

UriError.authorityUserInfoIsInvalidif the user info exists, but is invalid.

UriError.authorityPortIsInvalidif the port exists, but is invalid.

UriError.authorityHostIsInvalidif the host exists, but is invalid.

Returns

A Resultindicating whether the parsing was successful or not.