aboutsummaryrefslogtreecommitdiff
path: root/src/rpcserver.cpp
diff options
context:
space:
mode:
authorkazcw <keziahw@gmail.com>2014-06-28 18:14:36 -0700
committerkazcw <keziahw@gmail.com>2014-06-28 19:16:15 -0700
commit16f33f163d4e2c10320a96a22bbab71c9a0df195 (patch)
tree79b08ef53736fad40976c529142530cd42689f1f /src/rpcserver.cpp
parent7b8fc9d8ad4791269fb8439126b5ceff39217f56 (diff)
fix RPC error replies
After pull #4288, RPC messages indicating errors have a Content-Length unrelated to their actual contents, rendering bitcoin-cli and curl unable to decode the reply. This patch sets the Content-Length field based on the actual content returned. Additionally, pull #4288 clobbered the error descriptions provided in ErrorReply, which bitcoin-cli relies upon; this patch moves #4288 http-error descriptions to an HTTPError method, allowing HTTPReply to pass content on unchanged.
Diffstat (limited to 'src/rpcserver.cpp')
-rw-r--r--src/rpcserver.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index 6a87c8bf99..f47b3385da 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -481,7 +481,7 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol,
{
// Only send a 403 if we're not using SSL to prevent a DoS during the SSL handshake.
if (!fUseSSL)
- conn->stream() << HTTPReply(HTTP_FORBIDDEN, "", false) << std::flush;
+ conn->stream() << HTTPError(HTTP_FORBIDDEN, false) << std::flush;
conn->close();
}
else {
@@ -807,7 +807,7 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
// Check authorization
if (mapHeaders.count("authorization") == 0)
{
- conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush;
+ conn->stream() << HTTPError(HTTP_UNAUTHORIZED, false) << std::flush;
return false;
}
@@ -820,7 +820,7 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
if (mapArgs["-rpcpassword"].size() < 20)
MilliSleep(250);
- conn->stream() << HTTPReply(HTTP_UNAUTHORIZED, "", false) << std::flush;
+ conn->stream() << HTTPError(HTTP_UNAUTHORIZED, false) << std::flush;
return false;
}
@@ -888,7 +888,7 @@ void ServiceConnection(AcceptedConnection *conn)
if (!HTTPReq_JSONRPC(conn, strRequest, mapHeaders, fRun))
break;
} else {
- conn->stream() << HTTPReply(HTTP_NOT_FOUND, "", false) << std::flush;
+ conn->stream() << HTTPError(HTTP_NOT_FOUND, false) << std::flush;
break;
}
}