From 6b6f20a032eb31d747366c8bc270ca81731eaf6a Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Fri, 4 Sep 2026 17:09:24 +0200 Subject: Fixed pre-commit issues --- proxy/endpoints.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'proxy/endpoints.py') diff --git a/proxy/endpoints.py b/proxy/endpoints.py index 0a23e7b..f514226 100644 --- a/proxy/endpoints.py +++ b/proxy/endpoints.py @@ -1,13 +1,13 @@ import logging -from base64 import b64encode, b64decode +from base64 import b64decode, b64encode from uuid import uuid4 from starlette.endpoints import HTTPEndpoint from starlette.requests import Request from starlette.responses import Response -from proxy.utils import get_path_with_query_string from proxy.queue import ProxyQueue +from proxy.utils import get_path_with_query_string from ttun_server.types import HttpMessage, HttpMessageType, HttpRequestData logger = logging.getLogger(__name__) @@ -18,16 +18,15 @@ class HeaderMapping: self._headers = headers def items(self): - for header in self._headers: - yield header + yield from self._headers class Proxy(HTTPEndpoint): async def dispatch(self) -> None: request = Request(self.scope, self.receive) - subdomain = request.path_params['subdomain'] - response = Response(content='Not Found', status_code=404) + subdomain = request.path_params["subdomain"] + response = Response(content="Not Found", status_code=404) identifier = str(uuid4()) response_queue = await ProxyQueue.create_for_identifier(identifier) @@ -35,7 +34,7 @@ class Proxy(HTTPEndpoint): try: request_queue = await ProxyQueue.get_for_identifier(subdomain) - logger.debug('PROXY %s%s ', subdomain, request.url) + logger.debug("PROXY %s%s ", subdomain, request.url) await request_queue.enqueue( HttpMessage( type=HttpMessageType.request.value, @@ -44,17 +43,17 @@ class Proxy(HTTPEndpoint): method=request.method, path=get_path_with_query_string(request), headers=list(request.headers.items()), - body=b64encode(await request.body()).decode() - ) + body=b64encode(await request.body()).decode(), + ), ) ) _response = await response_queue.dequeue() - payload = _response['payload'] + payload = _response["payload"] response = Response( - status_code=payload['status'], - headers=HeaderMapping(payload['headers']), - content=b64decode(payload['body'].encode()) + status_code=payload["status"], + headers=HeaderMapping(payload["headers"]), + content=b64decode(payload["body"].encode()), ) except AssertionError: pass -- cgit v1.3