fix: trace was passed in the request method shortened url for trace
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
7bc73de128
commit
e2b7c5475f
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -25,9 +25,11 @@
|
|||||||
"metallum",
|
"metallum",
|
||||||
"musify",
|
"musify",
|
||||||
"OKBLUE",
|
"OKBLUE",
|
||||||
|
"pathvalidate",
|
||||||
"Referer",
|
"Referer",
|
||||||
"sponsorblock",
|
"sponsorblock",
|
||||||
"tracksort",
|
"tracksort",
|
||||||
|
"translit",
|
||||||
"unmap",
|
"unmap",
|
||||||
"youtube"
|
"youtube"
|
||||||
]
|
]
|
||||||
|
@ -16,6 +16,7 @@ from .cache import Cache
|
|||||||
from .rotating import RotatingProxy
|
from .rotating import RotatingProxy
|
||||||
from ..objects import Target
|
from ..objects import Target
|
||||||
from ..utils import request_trace
|
from ..utils import request_trace
|
||||||
|
from ..utils.string_processing import shorten_display_url
|
||||||
from ..utils.config import main_settings
|
from ..utils.config import main_settings
|
||||||
from ..utils.support_classes.download_result import DownloadResult
|
from ..utils.support_classes.download_result import DownloadResult
|
||||||
from ..utils.hacking import merge_args
|
from ..utils.hacking import merge_args
|
||||||
@ -149,8 +150,6 @@ class Connection:
|
|||||||
exclude_headers: List[str] = None,
|
exclude_headers: List[str] = None,
|
||||||
**kwargs
|
**kwargs
|
||||||
) -> Optional[requests.Response]:
|
) -> Optional[requests.Response]:
|
||||||
trace_string = f"{method} {url} \t{'[stream]' if kwargs.get('stream', False) else ''}"
|
|
||||||
|
|
||||||
if method is None:
|
if method is None:
|
||||||
raise AttributeError("method is not set.")
|
raise AttributeError("method is not set.")
|
||||||
method = method.upper()
|
method = method.upper()
|
||||||
@ -163,6 +162,7 @@ class Connection:
|
|||||||
current_kwargs.update(**kwargs)
|
current_kwargs.update(**kwargs)
|
||||||
|
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
|
trace_string = f"{method} {shorten_display_url(url)} \t{'[stream]' if kwargs.get('stream', False) else ''}"
|
||||||
|
|
||||||
if not raw_headers:
|
if not raw_headers:
|
||||||
_headers = copy.copy(self.HEADER_VALUES)
|
_headers = copy.copy(self.HEADER_VALUES)
|
||||||
|
@ -178,3 +178,9 @@ def match_length(length_1: int | None, length_2: int | None) -> bool:
|
|||||||
if length_1 is None or length_2 is None:
|
if length_1 is None or length_2 is None:
|
||||||
return True
|
return True
|
||||||
return abs(length_1 - length_2) <= ALLOWED_LENGTH_DISTANCE
|
return abs(length_1 - length_2) <= ALLOWED_LENGTH_DISTANCE
|
||||||
|
|
||||||
|
def shorten_display_url(url: str, max_length: int = 150, chars_at_end: int = 4, shorten_string: str = "[...]") -> str:
|
||||||
|
if len(url) <= max_length + chars_at_end + len(shorten_string):
|
||||||
|
return url
|
||||||
|
|
||||||
|
return url[:max_length] + shorten_string + url[-chars_at_end:]
|
||||||
|
Loading…
Reference in New Issue
Block a user