[#345] Fix curl request generation

Signed-off-by: Kirill Sosnovskikh <k.sosnovskikh@yadro.com>
This commit is contained in:
k.sosnovskikh 2025-01-10 14:29:03 +03:00 committed by k.sosnovskikh
parent 5a291c5b7f
commit daf186690b

View file

@ -134,9 +134,10 @@ class HttpClient:
@classmethod
def _create_curl_request(cls, url: str, method: str, headers: httpx.Headers, data: str, files: dict) -> str:
headers = " ".join(f'-H "{name.title()}: {value}"' for name, value in headers.items())
data = f" -d '{data}'" if data else ""
excluded_headers = {"Accept-Encoding", "Connection", "User-Agent", "Content-Length"}
headers = " ".join(f"-H '{header.title()}: {value}'" for header, value in headers.items() if header.title() not in excluded_headers)
data = f" -d '{data}'" if data else ""
for name, path in files.items():
data += f' -F "{name}=@{path}"'