diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2014-06-04 11:24:43 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2014-06-26 23:32:18 -0400 |
commit | c912e22db08d0a44ad6fd027c09bbdf79c34dbbc (patch) | |
tree | 0eb4939d21c7900a4bbbcdb35488d898bf2d3999 /src/rpcprotocol.h | |
parent | 236ae8665efadf7b4456c0a9fbf204a5cb4ce9f4 (diff) |
RPC cleanup: Improve HTTP server replies
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
Diffstat (limited to 'src/rpcprotocol.h')
-rw-r--r-- | src/rpcprotocol.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h index 11bdd171d9..8d415efb1b 100644 --- a/src/rpcprotocol.h +++ b/src/rpcprotocol.h @@ -71,6 +71,16 @@ enum RPCErrorCode RPC_WALLET_ALREADY_UNLOCKED = -17, // Wallet is already unlocked }; +class AcceptedConnection +{ +public: + virtual ~AcceptedConnection() {} + + virtual std::iostream& stream() = 0; + virtual std::string peer_address_to_string() const = 0; + virtual void close() = 0; +}; + // // IOStream device that speaks SSL but can also speak non-SSL // @@ -141,7 +151,9 @@ private: }; std::string HTTPPost(const std::string& strMsg, const std::map<std::string,std::string>& mapRequestHeaders); -std::string HTTPReply(int nStatus, const std::string& strMsg, bool keepalive); +std::string HTTPReply(int nStatus, const std::string& strMsg, bool keepalive, + bool headerOnly = false, + const char *contentType = "application/json"); bool ReadHTTPRequestLine(std::basic_istream<char>& stream, int &proto, std::string& http_method, std::string& http_uri); int ReadHTTPStatus(std::basic_istream<char>& stream, int &proto); |