MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / SendRequest

Method SendRequest

src/bitcoin-cli.cpp:907–935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

905}
906
907bool HTTPClient::SendRequest(std::string_view request)
908{
909 const auto deadline{std::chrono::steady_clock::now() + m_timeout};
910
911 while (!request.empty()) {
912 Sock::Event event{0};
913 auto time_left = std::chrono::duration_cast<std::chrono::milliseconds>(
914 deadline - std::chrono::steady_clock::now());
915 if (time_left.count() <= 0 || !m_socket->Wait(time_left, Sock::SendEvent, &event)) {
916 return false;
917 }
918
919 if (!(event & Sock::SendEvent)) {
920 continue;
921 }
922
923 ssize_t sent = m_socket->Send(request.data(), request.size(), MSG_NOSIGNAL);
924 if (sent < 0) {
925 int err = WSAGetLastError();
926 if (!IOErrorIsPermanent(err)) {
927 std::this_thread::yield();
928 continue;
929 }
930 return false;
931 }
932 request.remove_prefix(sent);
933 }
934 return true;
935}
936
937HTTPResponse HTTPClient::ReadResponse()
938{

Callers

nothing calls this directly

Calls 7

IOErrorIsPermanentFunction · 0.85
countMethod · 0.80
emptyMethod · 0.45
WaitMethod · 0.45
SendMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected