nit: Could just initialize to plain const C-array directly and then send as span:
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -849,7 +849,7 @@ public:
static HTTPClient Connect(const std::string& host, uint16_t port, std::chrono::seconds timeout);
HTTPResponse Post(const std::string& endpoint,
- const std::vector<std::pair<std::string, std::string>>& headers,
+ std::span<const std::pair<std::string, std::string>> headers,
const std::string& body);
private:
@@ -880,7 +880,7 @@ HTTPClient HTTPClient::Connect(const std::string& host, uint16_t port, std::chro
}
HTTPResponse HTTPClient::Post(const std::string& endpoint,
- const std::vector<std::pair<std::string, std::string>>& headers,
+ std::span<const std::pair<std::string, std::string>> headers,
const std::string& body)
{
try {
@@ -1204,10 +1204,10 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co
rpc_credentials = username + ":" + gArgs.GetArg("-rpcpassword", "");
}
- std::vector<std::pair<std::string, std::string>> headers;
- headers.emplace_back("Content-Type", "application/json");
- headers.emplace_back("Authorization", "Basic " + EncodeBase64(rpc_credentials));
-
+ const std::pair<std::string, std::string> headers[]{
+ {"Content-Type", "application/json"},
+ {"Authorization", "Basic " + EncodeBase64(rpc_credentials)},
+ };
std::string strRequest = rh->PrepareRequest(strMethod, args).write() + "\n";
HTTPResponse response;