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_
std::string parseRequest(std::string const &xml, XmlRpcValue &params)
Definition: FileClient.cpp:74
A class to handle XML RPC requests from a particular client.
RPC method arguments and results are represented by Values.
Definition: XmlRpcValue.h:24
ServerConnectionState _connectionState
static const std::string SYSTEM_MULTICALL
static const std::string FAULTCODE
static const std::string FAULTSTRING
An RPC source represents a file descriptor to monitor.
Definition: XmlRpcSource.h:16
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:52
A class to handle XML RPC requests.
Definition: XmlRpcServer.h:41
static const std::string METHODNAME


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas
autogenerated on Mon Feb 28 2022 23:33:22