Drop `Origin` from public API (#688)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
- 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
authored by Andrés Álvarez · committed by Tom Christie · parent f17ab37 · Browse files · 6 files·+9 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Tom Christie <tom@tomchristie.com>
Diff stats
6 files+9 added−12 removed
- tests:+2 added−1 removed
- other:+7 added−11 removed
Provenance
- Commit
2b92a78- Tree
9210ec0- Author
Andrés Álvarez <BigChief45@users.noreply.github.com>- Committer
Tom Christie <tom@tomchristie.com>- Parent
f17ab37
6 files changed+9 added−12 removed
modified:httpx/dispatch/connection_pool.py+1 added-1 removed
145 unmodified lines146 147 async def send(self, request: Request, timeout: Timeout = None) -> Response:148 await self.check_keepalive_expiry()149 connection = await self.acquire_connection(150- origin=request.url.origin, timeout=timeout150+ origin=Origin(request.url), timeout=timeout151 )152 try:153 response = await connection.send(request, timeout=timeout)154 except BaseException as exc:67 unmodified linesmodified:httpx/dispatch/proxy_http.py+3 added-3 removed
100 unmodified lines101 if self.should_forward_origin(origin):102 logger.trace(103 f"forward_connection proxy_url={self.proxy_url!r} origin={origin!r}"104 )105- return await super().acquire_connection(self.proxy_url.origin, timeout)105+ return await super().acquire_connection(Origin(self.proxy_url), timeout)106 else:107 logger.trace(108 f"tunnel_connection proxy_url={self.proxy_url!r} origin={origin!r}"109 )36 unmodified lines146 147 await self.max_connections.acquire()148 149 connection = HTTPConnection(150- self.proxy_url.origin,150+ Origin(self.proxy_url),151 ssl=self.tunnel_ssl,152 backend=self.backend,153 release_func=self.release_connection,154 )32 unmodified lines187 self.proxy_mode == DEFAULT_MODE and not origin.is_ssl188 ) or self.proxy_mode == FORWARD_ONLY189 190 async def send(self, request: Request, timeout: Timeout = None) -> Response:191- if self.should_forward_origin(request.url.origin):191+ if self.should_forward_origin(Origin(request.url)):192 # Change the request to have the target URL193 # as its full_path and switch the proxy URL194 # for where the request will be sent.195 target_url = str(request.url)13 unmodified linesmodified:httpx/__init__.py+1 added-2 removed
24 unmodified lines25 TimeoutException,26 TooManyRedirects,27 WriteTimeout,28 )29-from .models import URL, Cookies, Headers, Origin, QueryParams, Request, Response29+from .models import URL, Cookies, Headers, QueryParams, Request, Response30 from .status_codes import StatusCode, codes31 32 __all__ = [33 "__description__",41 unmodified lines75 "URL",76 "StatusCode",77 "Cookies",78 "Headers",79- "Origin",79 "QueryParams",80 "Request",81 "TimeoutException",82 "Response",2 unmodified linesmodified:httpx/client.py+2 added-1 removed
37 unmodified lines38 Cookies,39 CookieTypes,40 Headers,41 HeaderTypes,42+ Origin,43 QueryParams,44 QueryParamTypes,45 Request,46 RequestData,464 unmodified lines511 Return the headers that should be used for the redirect request.512 """513 headers = Headers(request.headers)514 514- if url.origin != request.url.origin:515+ if Origin(url) != Origin(request.url):516 # Strip Authorization headers when responses are redirected away from517 # the origin.518 headers.pop("Authorization", None)519 headers["Host"] = url.authority523 unmodified linesmodified:httpx/models.py-4 removed
190 unmodified lines191 @property192 def is_relative_url(self) -> bool:193 return not self.is_absolute_url194 195- @property196- def origin(self) -> "Origin":197- return Origin(self)198-195 def copy_with(self, **kwargs: typing.Any) -> "URL":196 if (197 "username" in kwargs198 or "password" in kwargs975 unmodified linesmodified:tests/models/test_url.py+2 added-1 removed
1 import pytest2 3-from httpx import URL, InvalidURL, Origin3+from httpx import URL, InvalidURL4+from httpx.models import Origin5 6 7 @pytest.mark.parametrize(8 "given,idna,host,scheme,port",198 unmodified lines