Skip to content
Myr

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

6 files+9 added−12 removed

modified:httpx/dispatch/connection_pool.py+1 added-1 removed
145 unmodified lines
146147 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 lines
modified:httpx/dispatch/proxy_http.py+3 added-3 removed
100 unmodified lines
101 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 lines
146147 await self.max_connections.acquire()148149 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 lines
187 self.proxy_mode == DEFAULT_MODE and not origin.is_ssl188 ) or self.proxy_mode == FORWARD_ONLY189190 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 lines
modified:httpx/__init__.py+1 added-2 removed
24 unmodified lines
25 TimeoutException,26 TooManyRedirects,27 WriteTimeout,28)29from .models import URL, Cookies, Headers, Origin, QueryParams, Request, Response29from .models import URL, Cookies, Headers, QueryParams, Request, Response30from .status_codes import StatusCode, codes3132__all__ = [33 "__description__",
41 unmodified lines
75 "URL",76 "StatusCode",77 "Cookies",78 "Headers",79 "Origin",79 "QueryParams",80 "Request",81 "TimeoutException",82 "Response",
2 unmodified lines
modified:httpx/client.py+2 added-1 removed
37 unmodified lines
38 Cookies,39 CookieTypes,40 Headers,41 HeaderTypes,42 Origin,43 QueryParams,44 QueryParamTypes,45 Request,46 RequestData,
464 unmodified lines
511 Return the headers that should be used for the redirect request.512 """513 headers = Headers(request.headers)514514 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.authority
523 unmodified lines
modified:httpx/models.py-4 removed
190 unmodified lines
191 @property192 def is_relative_url(self) -> bool:193 return not self.is_absolute_url194195 @property196 def origin(self) -> "Origin":197 return Origin(self)198195 def copy_with(self, **kwargs: typing.Any) -> "URL":196 if (197 "username" in kwargs198 or "password" in kwargs
975 unmodified lines
modified:tests/models/test_url.py+2 added-1 removed
1import pytest23from httpx import URL, InvalidURL, Origin3from httpx import URL, InvalidURL4from httpx.models import Origin567@pytest.mark.parametrize(8 "given,idna,host,scheme,port",
198 unmodified lines