MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / HTTPPost

Function HTTPPost

src/rpc/core/rpcprotocol.cpp:33–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31//
32
33string HTTPPost(const string& strMsg, const map<string, string>& mapRequestHeaders) {
34 ostringstream s;
35 s << "POST / HTTP/1.1\r\n"
36 << "User-Agent: Coin-json-rpc/" << FormatFullVersion() << "\r\n"
37 << "Host: 127.0.0.1\r\n"
38 << "Content-Type: application/json\r\n"
39 << "Content-Length: " << strMsg.size() << "\r\n"
40 << "Connection: close\r\n"
41 << "Access-Control-Allow-Origin: *"
42 << "\r\n"
43 << "Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS, DELETE, PATCH"
44 << "\r\n"
45 << "Access-Control-Max-Age: 3600"
46 << "\r\n"
47 << "Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"
48 << "\r\n"
49 << "Accept: application/json\r\n";
50 for (const auto& item : mapRequestHeaders)
51 s << item.first << ": " << item.second << "\r\n";
52 s << "\r\n" << strMsg;
53
54 return s.str();
55}
56
57static string rfc1123Time() { return DateTimeStrFormat("%a, %d %b %Y %H:%M:%S +0000", GetTime()); }
58

Callers 1

CallRPCFunction · 0.85

Calls 3

FormatFullVersionFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected