| 62 | static HTTPRPCTimerInterface* httpRPCTimerInterface = 0; |
| 63 | |
| 64 | static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const UniValue& id) |
| 65 | { |
| 66 | // Send error reply from json-rpc error object |
| 67 | int nStatus = HTTP_INTERNAL_SERVER_ERROR; |
| 68 | int code = find_value(objError, "code").get_int(); |
| 69 | |
| 70 | if (code == RPC_INVALID_REQUEST) |
| 71 | nStatus = HTTP_BAD_REQUEST; |
| 72 | else if (code == RPC_METHOD_NOT_FOUND) |
| 73 | nStatus = HTTP_NOT_FOUND; |
| 74 | |
| 75 | std::string strReply = JSONRPCReply(NullUniValue, objError, id); |
| 76 | |
| 77 | if (req->isChunkMode()) { |
| 78 | // in chunk mode, we assume that the handler had already set the response content-type |
| 79 | req->Chunk(strReply); |
| 80 | req->ChunkEnd(); |
| 81 | } else { |
| 82 | req->WriteHeader("Content-Type", "application/json"); |
| 83 | req->WriteReply(nStatus, strReply); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | static bool RPCAuthorized(const std::string& strAuth) |
| 88 | { |
no test coverage detected