- Drop the url.origin property.
- Drop Origin from the top-level export.
- Use origin = Origin(url) in our internal usage, rather than
url.origin.
Closes #656
Co-authored-by: Tom Christie <tom@tomchristie.com>
TooManyRedirects,
WriteTimeout,
)
-from .models import URL, Cookies, Headers, Origin, QueryParams, Request, Response
+from .models import URL, Cookies, Headers, QueryParams, Request, Response
from .status_codes import StatusCode, codes
__all__ = [
"StatusCode",
"Cookies",
"Headers",
- "Origin",
"QueryParams",
"Request",
"TimeoutException",
CookieTypes,
Headers,
HeaderTypes,
+ Origin,
QueryParams,
QueryParamTypes,
Request,
"""
headers = Headers(request.headers)
- if url.origin != request.url.origin:
+ if Origin(url) != Origin(request.url):
# Strip Authorization headers when responses are redirected away from
# the origin.
headers.pop("Authorization", None)
async def send(self, request: Request, timeout: Timeout = None) -> Response:
await self.check_keepalive_expiry()
connection = await self.acquire_connection(
- origin=request.url.origin, timeout=timeout
+ origin=Origin(request.url), timeout=timeout
)
try:
response = await connection.send(request, timeout=timeout)
logger.trace(
f"forward_connection proxy_url={self.proxy_url!r} origin={origin!r}"
)
- return await super().acquire_connection(self.proxy_url.origin, timeout)
+ return await super().acquire_connection(Origin(self.proxy_url), timeout)
else:
logger.trace(
f"tunnel_connection proxy_url={self.proxy_url!r} origin={origin!r}"
await self.max_connections.acquire()
connection = HTTPConnection(
- self.proxy_url.origin,
+ Origin(self.proxy_url),
ssl=self.tunnel_ssl,
backend=self.backend,
release_func=self.release_connection,
) or self.proxy_mode == FORWARD_ONLY
async def send(self, request: Request, timeout: Timeout = None) -> Response:
- if self.should_forward_origin(request.url.origin):
+ if self.should_forward_origin(Origin(request.url)):
# Change the request to have the target URL
# as its full_path and switch the proxy URL
# for where the request will be sent.
def is_relative_url(self) -> bool:
return not self.is_absolute_url
- @property
- def origin(self) -> "Origin":
- return Origin(self)
-
def copy_with(self, **kwargs: typing.Any) -> "URL":
if (
"username" in kwargs
import pytest
-from httpx import URL, InvalidURL, Origin
+from httpx import URL, InvalidURL
+from httpx.models import Origin
@pytest.mark.parametrize(