Iterator,
List,
Mapping,
+ NamedTuple,
Optional,
Sequence,
Tuple,
PrimitiveData = Optional[Union[str, int, float, bool]]
+RawURL = NamedTuple(
+ "RawURL",
+ [
+ ("raw_scheme", bytes),
+ ("raw_host", bytes),
+ ("port", Optional[int]),
+ ("raw_path", bytes),
+ ],
+)
+
URLTypes = Union["URL", str]
QueryParamTypes = Union[
import rfc3986.exceptions
from ._exceptions import InvalidURL
-from ._types import PrimitiveData, QueryParamTypes, URLTypes
+from ._types import PrimitiveData, QueryParamTypes, RawURL, URLTypes
from ._utils import primitive_value_to_str
"""
return unquote(self._uri_reference.fragment or "")
+ @property
+ def raw(self) -> RawURL:
+ """
+ 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.
+ """
+ return RawURL(
+ self.raw_scheme,
+ self.raw_host,
+ self.port,
+ self.raw_path,
+ )
+
@property
def is_absolute_url(self) -> bool:
"""
assert url.host == "::ffff:192.168.0.1"
assert url.netloc == b"[::ffff:192.168.0.1]"
assert str(url) == "https://[::ffff:192.168.0.1]/"
+
+
+def test_url_raw_compatibility():
+ url = httpx.URL("https://www.example.com/path")
+ scheme, host, port, raw_path = url.raw
+
+ assert scheme == b"https"
+ assert host == b"www.example.com"
+ assert port is None
+ assert raw_path == b"/path"