Changeset View
Changeset View
Standalone View
Standalone View
src/httprpc.cpp
// Copyright (c) 2015-2016 The Bitcoin Core developers | // Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
Lint: Code style violation: '/home/jason/projects/bitcoin-abc/src/httprpc.cpp' has code style errors. | |||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "httprpc.h" | #include "httprpc.h" | ||||
#include "base58.h" | #include "base58.h" | ||||
#include "chainparams.h" | #include "chainparams.h" | ||||
#include "config.h" | #include "config.h" | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | static bool checkCORS(HTTPRequest *req) { | ||||
// 4. If the list of exposed headers is not empty add one or more | // 4. If the list of exposed headers is not empty add one or more | ||||
// Access-Control-Expose-Headers headers, with as values the header | // Access-Control-Expose-Headers headers, with as values the header | ||||
// field names given in the list of exposed headers. | // field names given in the list of exposed headers. | ||||
req->WriteHeader("Access-Control-Expose-Headers", "WWW-Authenticate"); | req->WriteHeader("Access-Control-Expose-Headers", "WWW-Authenticate"); | ||||
return false; | return false; | ||||
} | } | ||||
static bool HTTPReq_JSONRPC(Config &config, HTTPRequest *req, | static bool HTTPReq_JSONRPC(Config &config, RPCServer &rpcServer, | ||||
const std::string &) { | HTTPRequest *req, const std::string &) { | ||||
// First, check and/or set CORS headers | // First, check and/or set CORS headers | ||||
if (checkCORS(req)) { | if (checkCORS(req)) { | ||||
return true; | return true; | ||||
} | } | ||||
// JSONRPC handles only POST | // JSONRPC handles only POST | ||||
if (req->GetRequestMethod() != HTTPRequest::POST) { | if (req->GetRequestMethod() != HTTPRequest::POST) { | ||||
req->WriteReply(HTTP_BAD_METHOD, | req->WriteReply(HTTP_BAD_METHOD, | ||||
Show All 32 Lines | try { | ||||
// Set the URI | // Set the URI | ||||
jreq.URI = req->GetURI(); | jreq.URI = req->GetURI(); | ||||
std::string strReply; | std::string strReply; | ||||
// singleton request | // singleton request | ||||
if (valRequest.isObject()) { | if (valRequest.isObject()) { | ||||
jreq.parse(valRequest); | jreq.parse(valRequest); | ||||
UniValue result = tableRPC.execute(config, jreq); | UniValue result = rpcServer.ExecuteCommand(config, jreq); | ||||
// Send reply | // Send reply | ||||
strReply = JSONRPCReply(result, NullUniValue, jreq.id); | strReply = JSONRPCReply(result, NullUniValue, jreq.id); | ||||
} else if (valRequest.isArray()) { | } else if (valRequest.isArray()) { | ||||
// array of requests | // array of requests | ||||
strReply = JSONRPCExecBatch(config, jreq, valRequest.get_array()); | strReply = JSONRPCExecBatch(config, rpcServer, jreq, | ||||
valRequest.get_array()); | |||||
} else { | } else { | ||||
throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error"); | throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error"); | ||||
} | } | ||||
req->WriteHeader("Content-Type", "application/json"); | req->WriteHeader("Content-Type", "application/json"); | ||||
req->WriteReply(HTTP_OK, strReply); | req->WriteReply(HTTP_OK, strReply); | ||||
} catch (const UniValue &objError) { | } catch (const UniValue &objError) { | ||||
JSONErrorReply(req, objError, jreq.id); | JSONErrorReply(req, objError, jreq.id); | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |
'/home/jason/projects/bitcoin-abc/src/httprpc.cpp' has code style errors.