mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Fix quoting in curl cmdline
Signed-off-by: Osyotr <Osyotr@users.noreply.github.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
d8f9323705
commit
416b8ab95a
@@ -186,7 +186,7 @@ bool HttpClient::RunHttpRequest()
|
|||||||
ScopedRemoveFile body_deleter;
|
ScopedRemoveFile body_deleter;
|
||||||
ScopedRemoveFile received_file_deleter;
|
ScopedRemoveFile received_file_deleter;
|
||||||
|
|
||||||
std::string cmd = "curl -s -w '%{http_code}' -D '" + headers_deleter.m_fileName + "' ";
|
std::string cmd = "curl -s -w \"%{http_code}\" -D \"" + headers_deleter.m_fileName + "\" ";
|
||||||
// From curl manual:
|
// From curl manual:
|
||||||
// This option [-X] only changes the actual word used in the HTTP request, it does not alter
|
// This option [-X] only changes the actual word used in the HTTP request, it does not alter
|
||||||
// the way curl behaves. So for example if you want to make a proper
|
// the way curl behaves. So for example if you want to make a proper
|
||||||
@@ -197,12 +197,12 @@ bool HttpClient::RunHttpRequest()
|
|||||||
cmd += "-X " + m_httpMethod + " ";
|
cmd += "-X " + m_httpMethod + " ";
|
||||||
|
|
||||||
for (auto const & header : m_headers)
|
for (auto const & header : m_headers)
|
||||||
cmd += "-H '" + header.first + ": " + header.second + "' ";
|
cmd += "-H \"" + header.first + ": " + header.second + "\" ";
|
||||||
|
|
||||||
if (!m_cookies.empty())
|
if (!m_cookies.empty())
|
||||||
cmd += "-b '" + m_cookies + "' ";
|
cmd += "-b \"" + m_cookies + "\" ";
|
||||||
|
|
||||||
cmd += "-m '" + strings::to_string(m_timeoutSec) + "' ";
|
cmd += "-m \"" + strings::to_string(m_timeoutSec) + "\" ";
|
||||||
|
|
||||||
if (!m_bodyData.empty())
|
if (!m_bodyData.empty())
|
||||||
{
|
{
|
||||||
@@ -216,7 +216,7 @@ bool HttpClient::RunHttpRequest()
|
|||||||
}
|
}
|
||||||
// Content-Length is added automatically by curl.
|
// Content-Length is added automatically by curl.
|
||||||
if (!m_inputFile.empty())
|
if (!m_inputFile.empty())
|
||||||
cmd += "--data-binary '@" + m_inputFile + "' ";
|
cmd += "--data-binary \"@" + m_inputFile + "\" ";
|
||||||
|
|
||||||
// Use temporary file to receive data from server.
|
// Use temporary file to receive data from server.
|
||||||
// If user has specified file name to save data, it is not temporary and is not deleted automatically.
|
// If user has specified file name to save data, it is not temporary and is not deleted automatically.
|
||||||
@@ -227,7 +227,7 @@ bool HttpClient::RunHttpRequest()
|
|||||||
received_file_deleter.m_fileName = rfile;
|
received_file_deleter.m_fileName = rfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd += "-o " + rfile + strings::to_string(" ") + "'" + m_urlRequested + "'";
|
cmd += "-o " + rfile + strings::to_string(" ") + "\"" + m_urlRequested + "\"";
|
||||||
|
|
||||||
LOG(LDEBUG, ("Executing", cmd));
|
LOG(LDEBUG, ("Executing", cmd));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user