XmlRpcServerConnection.h
Go to the documentation of this file.
1 #ifndef _XMLRPCSERVERCONNECTION_H_
2 #define _XMLRPCSERVERCONNECTION_H_
3 //
4 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
5 //
6 #if defined(_MSC_VER)
7 # pragma warning(disable:4786) // identifier was truncated in debug info
8 #endif
9 
10 #ifndef MAKEDEPEND
11 # include <string>
12 #endif
13 
14 #include "xmlrpcpp/XmlRpcValue.h"
15 #include "xmlrpcpp/XmlRpcSource.h"
16 #include "xmlrpcpp/XmlRpcDecl.h"
17 
18 namespace XmlRpc {
19 
20 
21  // The server waits for client connections and provides methods
22  class XmlRpcServer;
23  class XmlRpcServerMethod;
24 
27  public:
28  // Static data
29  static const char METHODNAME_TAG[];
30  static const char PARAMS_TAG[];
31  static const char PARAMS_ETAG[];
32  static const char PARAM_TAG[];
33  static const char PARAM_ETAG[];
34 
35  static const std::string SYSTEM_MULTICALL;
36  static const std::string METHODNAME;
37  static const std::string PARAMS;
38 
39  static const std::string FAULTCODE;
40  static const std::string FAULTSTRING;
41 
43  XmlRpcServerConnection(int fd, XmlRpcServer* server, bool deleteOnClose = false);
45  virtual ~XmlRpcServerConnection();
46 
47  // XmlRpcSource interface implementation
50  virtual unsigned handleEvent(unsigned eventType);
51 
52  protected:
53 
54  bool readHeader();
55  bool readRequest();
56  bool writeResponse();
57 
58  // Parses the request, runs the method, generates the response xml.
59  virtual void executeRequest();
60 
61  // Parse the methodName and parameters from the request.
62  std::string parseRequest(XmlRpcValue& params);
63 
64  // Execute a named method with the specified params.
65  bool executeMethod(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
66 
67  // Execute multiple calls and return the results in an array.
68  bool executeMulticall(const std::string& methodName, XmlRpcValue& params, XmlRpcValue& result);
69 
70  // Construct a response from the result XML.
71  void generateResponse(std::string const& resultXml);
72  void generateFaultResponse(std::string const& msg, int errorCode = -1);
73  std::string generateHeader(std::string const& body);
74 
75 
76  // The XmlRpc server that accepted this connection
78 
79  // Possible IO states for the connection
80  enum ServerConnectionState { READ_HEADER, READ_REQUEST, WRITE_RESPONSE };
82 
83  // Request headers
84  std::string _header;
85 
86  // Number of bytes expected in the request body (parsed from header)
88 
89  // Request body
90  std::string _request;
91 
92  // Response
93  std::string _response;
94 
95  // Number of bytes of the response written so far
97 
98  // Whether to keep the current client connection open for further requests
99  bool _keepAlive;
100  };
101 } // namespace XmlRpc
102 
103 #endif // _XMLRPCSERVERCONNECTION_H_
XmlRpc::XmlRpcServerConnection::_bytesWritten
int _bytesWritten
Definition: XmlRpcServerConnection.h:96
XmlRpc::XmlRpcServerConnection::_header
std::string _header
Definition: XmlRpcServerConnection.h:84
XmlRpc::XmlRpcServer
A class to handle XML RPC requests.
Definition: XmlRpcServer.h:41
XmlRpc::XmlRpcServerConnection::METHODNAME
static const std::string METHODNAME
Definition: XmlRpcServerConnection.h:36
XmlRpc::XmlRpcServerConnection::_contentLength
int _contentLength
Definition: XmlRpcServerConnection.h:87
XmlRpc::XmlRpcServerConnection::FAULTCODE
static const std::string FAULTCODE
Definition: XmlRpcServerConnection.h:39
XmlRpcValue.h
XmlRpc::XmlRpcServerConnection::ServerConnectionState
ServerConnectionState
Definition: XmlRpcServerConnection.h:80
XmlRpc::XmlRpcServerConnection::_response
std::string _response
Definition: XmlRpcServerConnection.h:93
XmlRpc
Definition: XmlRpcClient.h:20
XmlRpc::XmlRpcServerConnection::_keepAlive
bool _keepAlive
Definition: XmlRpcServerConnection.h:99
parseRequest
std::string parseRequest(std::string const &xml, XmlRpcValue &params)
Definition: FileClient.cpp:74
XmlRpcDecl.h
XmlRpc::XmlRpcSource
An RPC source represents a file descriptor to monitor.
Definition: XmlRpcSource.h:16
XmlRpcSource.h
XmlRpc::XmlRpcServerConnection::SYSTEM_MULTICALL
static const std::string SYSTEM_MULTICALL
Definition: XmlRpcServerConnection.h:35
XmlRpc::XmlRpcServerConnection::_server
XmlRpcServer * _server
Definition: XmlRpcServerConnection.h:77
XmlRpc::XmlRpcServerConnection::FAULTSTRING
static const std::string FAULTSTRING
Definition: XmlRpcServerConnection.h:40
XmlRpc::XmlRpcServerConnection::_connectionState
ServerConnectionState _connectionState
Definition: XmlRpcServerConnection.h:81
XmlRpc::XmlRpcServerConnection::PARAMS
static const std::string PARAMS
Definition: XmlRpcServerConnection.h:37
XMLRPCPP_DECL
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:52
XmlRpc::XmlRpcServerConnection
A class to handle XML RPC requests from a particular client.
Definition: XmlRpcServerConnection.h:26
XmlRpc::XmlRpcValue
RPC method arguments and results are represented by Values.
Definition: XmlRpcValue.h:24
XmlRpc::XmlRpcServerConnection::_request
std::string _request
Definition: XmlRpcServerConnection.h:90


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas , Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:32