from starlette.requests import HTTPConnection def get_path_with_query_string(connection: HTTPConnection) -> str: path = connection.url.path query_string = '?' + connection.scope['query_string'].decode() if connection.scope['query_string'] else '' return f"{path}{query_string}"