1
#ifndef _XMLRPCSERVERCONNECTION_H_
2
#define _XMLRPCSERVERCONNECTION_H_
4
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
7
# pragma warning(disable:4786) // identifier was truncated in debug info
14
#include "XmlRpcValue.h"
15
#include "XmlRpcSource.h"
20
// The server waits for client connections and provides methods
22
class XmlRpcServerMethod;
24
//! A class to handle XML RPC requests from a particular client
25
class XmlRpcServerConnection : public XmlRpcSource {
28
static const char METHODNAME_TAG[];
29
static const char PARAMS_TAG[];
30
static const char PARAMS_ETAG[];
31
static const char PARAM_TAG[];
32
static const char PARAM_ETAG[];
34
static const std::string SYSTEM_MULTICALL;
35
static const std::string METHODNAME;
36
static const std::string PARAMS;
38
static const std::string FAULTCODE;
39
static const std::string FAULTSTRING;
42
XmlRpcServerConnection(int fd, XmlRpcServer* server, bool deleteOnClose = false);
44
virtual ~XmlRpcServerConnection();
46
// XmlRpcSource interface implementation
47
//! Handle IO on the client connection socket.
48
//! @param eventType Type of IO event that occurred. @see XmlRpcDispatch::EventType.
49
virtual unsigned handleEvent(unsigned eventType);
57
// Parses the request, runs the method, generates the response xml.
58
virtual void executeRequest();
60
// Parse the methodName and parameters from the request.
61
std::string parseRequest(XmlRpcValue& params);
63
// Execute a named method with the specified params.
64
bool executeMethod(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
66
// Execute multiple calls and return the results in an array.
67
bool executeMulticall(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
69
// Construct a response from the result XML.
70
void generateResponse(std::string const& resultXml);
71
void generateFaultResponse(std::string const& msg, int errorCode = -1);
72
std::string generateHeader(std::string const& body);
75
// The XmlRpc server that accepted this connection
76
XmlRpcServer* _server;
78
// Possible IO states for the connection
79
enum ServerConnectionState { READ_HEADER, READ_REQUEST, WRITE_RESPONSE };
80
ServerConnectionState _connectionState;
85
// Number of bytes expected in the request body (parsed from header)
92
std::string _response;
94
// Number of bytes of the response written so far
97
// Whether to keep the current client connection open for further requests
100
} // namespace XmlRpc
102
#endif // _XMLRPCSERVERCONNECTION_H_