Initial commit

This commit is contained in:
kdusek
2025-12-09 12:13:01 +01:00
commit 8e654ed209
13332 changed files with 2695056 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
from typing import Optional
import httpcore
def file_key_generator(request: httpcore.Request, body: Optional[bytes]) -> str:
"""Generates a stable, readable key for a given request.
Args:
request (httpcore.Request): _description_
body (bytes): _description_
Returns:
str: Persistent key for the request
"""
host = request.url.host.decode()
path_b, _, query_b = request.url.target.partition(b"?")
path = path_b.decode()
query = query_b.decode()
url_p = path.replace("/", "__") + (f"__{query.replace('&', '__').replace('=', '__')}" if query else "")
key = f"{host}_{url_p}"
return key