class URL: (source)
url = httpx.URL("HTTPS://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink") assert url.scheme == "https" assert url.username == "jo@email.com" assert url.password == "a secret" assert url.userinfo == b"jo%40email.com:a%20secret" assert url.host == "müller.de" assert url.raw_host == b"xn--mller-kva.de" assert url.port == 1234 assert url.netloc == b"xn--mller-kva.de:1234" assert url.path == "/pa th" assert url.query == b"?search=ab" assert url.raw_path == b"/pa%20th?search=ab" assert url.fragment == "anchorlink" The components of a URL are broken down like this: https://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink [scheme] [ username ] [password] [ host ][port][ path ] [ query ] [fragment] [ userinfo ] [ netloc ][ raw_path ] Note that: * `url.scheme` is normalized to always be lowercased. * `url.host` is normalized to always be lowercased. Internationalized domain names are represented in unicode, without IDNA encoding applied. For instance: url = httpx.URL("http://中国.icom.museum") assert url.host == "中国.icom.museum" url = httpx.URL("http://xn--fiqs8s.icom.museum") assert url.host == "中国.icom.museum" * `url.raw_host` is normalized to always be lowercased, and is IDNA encoded. url = httpx.URL("http://中国.icom.museum") assert url.raw_host == b"xn--fiqs8s.icom.museum" url = httpx.URL("http://xn--fiqs8s.icom.museum") assert url.raw_host == b"xn--fiqs8s.icom.museum" * `url.port` is either None or an integer. URLs that include the default port for "http", "https", "ws", "wss", and "ftp" schemes have their port normalized to `None`. assert httpx.URL("http://example.com") == httpx.URL("http://example.com:80") assert httpx.URL("http://example.com").port is None assert httpx.URL("http://example.com:80").port is None * `url.userinfo` is raw bytes, without URL escaping. Usually you'll want to work with `url.username` and `url.password` instead, which handle the URL escaping. * `url.raw_path` is raw bytes of both the path and query, without URL escaping. This portion is used as the target when constructing HTTP requests. Usually you'll want to work with `url.path` instead. * `url.query` is raw bytes, without URL escaping. A URL query string portion can only be properly URL escaped when decoding the parameter names and values themselves.
Method | __eq__ |
Undocumented |
Method | __hash__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __str__ |
Undocumented |
Method | copy |
Undocumented |
Method | copy |
Undocumented |
Method | copy |
Undocumented |
Method | copy |
Undocumented |
Method | copy |
Copy this URL, returning a new URL with some components altered. Accepts the same set of parameters as the components that are made available via properties on the `URL` class. |
Method | join |
Return an absolute URL, using this URL as the base. |
Property | fragment |
The URL fragments, as used in HTML anchors. As a string, without the leading '#'. |
Property | host |
The URL host as a string. Always normalized to lowercase, with IDNA hosts decoded into unicode. |
Property | is |
Return `True` for absolute URLs such as 'http://example.com/path', and `False` for relative URLs such as '/path'. |
Property | is |
Return `False` for absolute URLs such as 'http://example.com/path', and `True` for relative URLs such as '/path'. |
Property | netloc |
Either `<host>` or `<host>:<port>` as bytes. Always normalized to lowercase, and IDNA encoded. |
Property | params |
The URL query parameters, neatly parsed and packaged into an immutable multidict representation. |
Property | password |
The URL password as a string, with URL decoding applied. For example: "a secret" |
Property | path |
The URL path as a string. Excluding the query string, and URL decoded. |
Property | port |
The URL port as an integer. |
Property | query |
The URL query string, as raw bytes, excluding the leading b"?". |
Property | raw |
Provides the (scheme, host, port, target) for the outgoing request. |
Property | raw |
The raw bytes representation of the URL host. Always normalized to lowercase, and IDNA encoded. |
Property | raw |
The complete URL path and query string as raw bytes. Used as the target when constructing HTTP requests. |
Property | raw |
The raw bytes representation of the URL scheme, such as b"http", b"https". Always normalised to lowercase. |
Property | scheme |
The URL scheme, such as "http", "https". Always normalised to lowercase. |
Property | userinfo |
The URL userinfo as a raw bytestring. For example: b"jo%40email.com:a%20secret". |
Property | username |
The URL username as a string, with URL decoding applied. For example: "jo@email.com" |
Instance Variable | _uri |
Undocumented |
Copy this URL, returning a new URL with some components altered. Accepts the same set of parameters as the components that are made available via properties on the `URL` class. For example: url = httpx.URL("https://www.example.com").copy_with(username="jo@gmail.com", password="a secret") assert url == "https://jo%40email.com:a%20secret@www.example.com"
Parameters | |
**kwargs:typing.Any | Undocumented |
Returns | |
URL | Undocumented |
Return an absolute URL, using this URL as the base. Eg. url = httpx.URL("https://www.example.com/test") url = url.join("/new/path") assert url == "https://www.example.com/new/path"
Parameters | |
url:URLTypes | Undocumented |
Returns | |
URL | Undocumented |
The URL host as a string. Always normalized to lowercase, with IDNA hosts decoded into unicode. Examples: url = httpx.URL("http://www.EXAMPLE.org") assert url.host == "www.example.org" url = httpx.URL("http://中国.icom.museum") assert url.host == "中国.icom.museum" url = httpx.URL("http://xn--fiqs8s.icom.museum") assert url.host == "中国.icom.museum" url = httpx.URL("https://[::ffff:192.168.0.1]") assert url.host == "::ffff:192.168.0.1"
Return `True` for absolute URLs such as 'http://example.com/path', and `False` for relative URLs such as '/path'.
Return `False` for absolute URLs such as 'http://example.com/path', and `True` for relative URLs such as '/path'.
Either `<host>` or `<host>:<port>` as bytes. Always normalized to lowercase, and IDNA encoded. This property may be used for generating the value of a request "Host" header.
The URL path as a string. Excluding the query string, and URL decoded. For example: url = httpx.URL("https://example.com/pa%20th") assert url.path == "/pa th"
The URL port as an integer. Note that the URL class performs port normalization as per the WHATWG spec. Default ports for "http", "https", "ws", "wss", and "ftp" schemes are always treated as `None`. For example: assert httpx.URL("http://www.example.com") == httpx.URL("http://www.example.com:80") assert httpx.URL("http://www.example.com:80").port is None
The URL query string, as raw bytes, excluding the leading b"?". This is necessarily a bytewise interface, because we cannot perform URL decoding of this representation until we've parsed the keys and values into a QueryParams instance. For example: url = httpx.URL("https://example.com/?filter=some%20search%20terms") assert url.query == b"filter=some%20search%20terms"
Provides the (scheme, host, port, target) for the outgoing request. In older versions of `httpx` this was used in the low-level transport API. We no longer use `RawURL`, and this property will be deprecated in a future release.
The raw bytes representation of the URL host. Always normalized to lowercase, and IDNA encoded. Examples: url = httpx.URL("http://www.EXAMPLE.org") assert url.raw_host == b"www.example.org" url = httpx.URL("http://中国.icom.museum") assert url.raw_host == b"xn--fiqs8s.icom.museum" url = httpx.URL("http://xn--fiqs8s.icom.museum") assert url.raw_host == b"xn--fiqs8s.icom.museum" url = httpx.URL("https://[::ffff:192.168.0.1]") assert url.raw_host == b"::ffff:192.168.0.1"
The complete URL path and query string as raw bytes. Used as the target when constructing HTTP requests. For example: GET /users?search=some%20text HTTP/1.1 Host: www.example.org Connection: close
The raw bytes representation of the URL scheme, such as b"http", b"https". Always normalised to lowercase.