| 31 | // |
| 32 | |
| 33 | string 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 | |
| 57 | static string rfc1123Time() { return DateTimeStrFormat("%a, %d %b %Y %H:%M:%S +0000", GetTime()); } |
| 58 |
no test coverage detected