| 258 | } |
| 259 | |
| 260 | static void ErrorReply(HTTPRequest* req, const json_spirit::Object& objError, |
| 261 | const json_spirit::Value& id) { |
| 262 | // Send error reply from json-rpc error object |
| 263 | int nStatus = HTTP_INTERNAL_SERVER_ERROR; |
| 264 | Value codeObj = json_spirit::find_value(objError, "code"); |
| 265 | if (codeObj.type() == int_type) { |
| 266 | int code = codeObj.get_int(); |
| 267 | |
| 268 | if (code == RPC_INVALID_REQUEST) |
| 269 | nStatus = HTTP_BAD_REQUEST; |
| 270 | else if (code == RPC_METHOD_NOT_FOUND) |
| 271 | nStatus = HTTP_NOT_FOUND; |
| 272 | } |
| 273 | std::string strReply = JSONRPCReply(Value::null, objError, id); |
| 274 | req->WriteHeader("Content-Type", "application/json"); |
| 275 | req->WriteReply(nStatus, strReply); |
| 276 | } |
| 277 | |
| 278 | static bool InitRPCAuthentication() { |
| 279 | strRPCUserColonPass = |
no test coverage detected