Closed lioncruise closed 3 years ago
You must send the Authorization
header, like this: Authorization: Basic am9objpwd2Q=
where dXNlcjpwYXNzd29yZA==
is base64-encoded string "user:password". Use can use https://www.base64encode.org to encode your user and password with base64.
You must send the
Authorization
header, like this:Authorization: Basic am9objpwd2Q=
wheredXNlcjpwYXNzd29yZA==
is base64-encoded string "user:password". Use can use https://www.base64encode.org to encode your user and password with base64.
@elvissstrazdins Thank you very much for your help!
@elvissstrazdins using your tip above, i wrote the following code:
std::vector<std::string> headers;
headers.push_back("Authorization: Basic ZWxhc3RpYzptaW5pVmlkZW9AMTIzNDU2");
const auto response = request.send("GET", "", headers);
std::cout << std::string{response.body.begin(), response.body.end()} << '\n';
the request stuck at this code in your include/HTTPRequest.hpp
file, while I can request successfully with curl -u
with the same HTTP auth and query url. I'm not familiar with network programming. what might be the problem?
auto count = ::select(endpoint + 1,
(type == SelectType::read) ? &descriptorSet : nullptr,
(type == SelectType::write) ? &descriptorSet : nullptr,
nullptr,
(timeout >= 0) ? &selectTimeout : nullptr);
HTTPRequest did not pass the port number in the request. This was fixed in https://github.com/elnormous/HTTPRequest/commit/cdaa3cd589205a1bc6f1057492aab42b14d2ebd5
I want to write a C++ HTTP client to query ES's RESTful API, but ES has user and password, I do it with curl -u user:password http://xxxx.