Some code movement and minor improvements, to prepare for HTTP REST support (#2844).
Even if HTTP REST is delayed or does not go in, these cleanups remain useful.
Some code movement and minor improvements, to prepare for HTTP REST support (#2844).
Even if HTTP REST is delayed or does not go in, these cleanups remain useful.
53 | @@ -54,7 +54,8 @@ static string rfc1123Time() 54 | return DateTimeStrFormat("%a, %d %b %Y %H:%M:%S +0000", GetTime()); 55 | } 56 | 57 | -string HTTPReply(int nStatus, const string& strMsg, bool keepalive) 58 | +string HTTPReply(int nStatus, const string& strMsg, bool keepalive, 59 | + bool headersOnly, const char *contentType)
Nit: You may use 4 spaces as identation here.
Untested ACK.
102 | @@ -94,8 +103,10 @@ string HTTPReply(int nStatus, const string& strMsg, bool keepalive) 103 | rfc1123Time(), 104 | keepalive ? "keep-alive" : "close", 105 | strMsg.size(), 106 | + contentType, 107 | FormatFullVersion(), 108 | - strMsg); 109 | + headersOnly ? "" :
Please use parentheses here. Multiple nested tertiary operators are harder to read, but more so if the grouping is not explicit.
ACK (apart from the above nit), this is a good step toward making the RPC mechanism more modular
1) support varying content types
2) support only sending the header
3) properly deliver error message as content, if HTTP error
4) move AcceptedConnection class to header, for wider use
Also, add parens to HTTPReply() to assist readability.
70 | @@ -71,6 +71,16 @@ enum RPCErrorCode 71 | RPC_WALLET_ALREADY_UNLOCKED = -17, // Wallet is already unlocked 72 | }; 73 | 74 | +class AcceptedConnection
This belongs in rpcserver.h, as it is specific to the server side.
Rebased and addressed feedback.
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4288_ed5769f536f663a8deb8e8b7a68681cebaa52bdd/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.