Documentation

Std.Http.Data.URI

URI #

This module defines the URI and RequestTarget types that represent and manipulate components of URIs as defined by RFC 3986. It provides parsing, rendering, and normalization utilities for working with URIs and request targets in HTTP messages.

References:

@[inline]

Attempts to parse a RequestTarget from the given string.

Equations
Instances For
    @[inline]

    Parses a RequestTarget from the given string. Panics if parsing fails. Use parse? if you need a safe option-returning version.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[inline]

      Creates an origin-form request target from a path string. The path should start with '/' (e.g., "/api/users" or "/search?q=test"). Panics if the string is not a valid origin-form request target.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Returns the path component of the request target, defaulting to the root path / when the target carries no path (asterisk-form or authority-form). Unlike RequestTarget.path, the fallback is the absolute root rather than an empty relative path — used by clients that need a well-formed absolute path for cookie matching or logging.

        Equations
        Instances For

          Inserts or appends a query parameter on this target, preserving its form. Origin-form and absolute-form targets gain the parameter on their existing query; authority-form and asterisk-form targets are returned unchanged because they do not carry a query.

          Equations
          Instances For
            @[inline]

            Attempts to parse a URIReference from the given string.

            Accepts both complete URIs (with scheme) and relative references (without scheme), per RFC 3986 §4.1. Relative references include protocol-relative (//host/path), absolute-path (/path), path-noscheme (../other, foo/bar), query-only (?q=1), fragment-only (#sec), and empty.

            Equations
            Instances For
              @[inline]

              Parses a URIReference from the given string. Panics if parsing fails. Use parse? if you need a safe option-returning version.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Extracts the numeric port this URI addresses. When the authority omits the port (or parses as empty) the scheme's default port is returned (80 for http, 443 for https).

                Equations
                Instances For

                  The host this URI addresses, or none when the URI carries no authority.

                  A URI without an authority cannot identify an origin to connect to, so callers that need to dispatch a request should treat none as malformed input rather than substituting a default host.

                  Equations
                  Instances For

                    Returns the origin-form request target corresponding to this URI, dropping the scheme, authority, user-info, and fragment while preserving the query component.

                    Reference: https://httpwg.org/specs/rfc9112.html#section-3.2.1

                    Equations
                    Instances For
                      @[inline]

                      Attempts to parse a URI from the given string.

                      Equations
                      Instances For
                        @[inline]

                        Parses a URI from the given string. Panics if parsing fails. Use parse? if you need a safe option-returning version.

                        Equations
                        Instances For
                          @[inline]

                          Attempts to parse a URI path from the given string. Returns none if the string is not a valid path.

                          Equations
                          Instances For
                            @[inline]

                            Parses a URI path from the given string. Returns the root path "/" if parsing fails.

                            Equations
                            Instances For