mirror of
https://github.com/UrloMythus/UnHided.git
synced 2026-06-10 09:10:23 +00:00
new version
This commit is contained in:
@@ -360,13 +360,21 @@ class Streamer:
|
||||
await self.session.close()
|
||||
|
||||
|
||||
async def download_file_with_retry(url: str, headers: dict) -> bytes:
|
||||
async def download_file_with_retry(
|
||||
url: str,
|
||||
headers: dict,
|
||||
timeout: typing.Optional[ClientTimeout] = None,
|
||||
) -> bytes:
|
||||
"""
|
||||
Downloads a file with retry logic.
|
||||
|
||||
Args:
|
||||
url: The URL of the file to download.
|
||||
headers: The headers to include in the request.
|
||||
timeout: Optional aiohttp ClientTimeout override. When None the global
|
||||
transport timeout is used. Pass a ClientTimeout with sock_read set
|
||||
(and total=None) for large ranged downloads so that the per-chunk
|
||||
read deadline is used instead of a hard total-download limit.
|
||||
|
||||
Returns:
|
||||
bytes: The downloaded file content.
|
||||
@@ -374,7 +382,7 @@ async def download_file_with_retry(url: str, headers: dict) -> bytes:
|
||||
Raises:
|
||||
DownloadError: If the download fails after retries.
|
||||
"""
|
||||
async with create_aiohttp_session(url) as (session, proxy_url):
|
||||
async with create_aiohttp_session(url, timeout=timeout) as (session, proxy_url):
|
||||
try:
|
||||
response = await fetch_with_retry(session, "GET", url, headers, proxy=proxy_url)
|
||||
return await response.read()
|
||||
@@ -689,6 +697,7 @@ class ProxyRequestHeaders:
|
||||
response: dict
|
||||
remove: list # headers to remove from response
|
||||
propagate: dict # response headers to propagate to segments (rp_ prefix)
|
||||
auto_added_range: bool = False # True if range header was auto-added by proxy (not from client)
|
||||
|
||||
|
||||
def apply_header_manipulation(
|
||||
@@ -754,6 +763,10 @@ def get_proxy_headers(request: Request) -> ProxyRequestHeaders:
|
||||
# Filter out empty values
|
||||
propagate_headers = {k[3:].lower(): v for k, v in request.query_params.items() if k.lower().startswith("rp_") and v}
|
||||
|
||||
for k, v in propagate_headers.items():
|
||||
if k not in request_headers:
|
||||
request_headers[k] = v
|
||||
|
||||
# Parse headers to remove from response (x_headers parameter)
|
||||
x_headers_param = request.query_params.get("x_headers", "")
|
||||
remove_headers = [h.strip().lower() for h in x_headers_param.split(",") if h.strip()] if x_headers_param else []
|
||||
|
||||
Reference in New Issue
Block a user