81 char *hp = (
char*)
_header.c_str();
87 for (
char *cp = hp; (bp == 0) && (cp <
ep); ++cp) {
88 if ((
ep - cp > 16) && (strncasecmp(cp,
"Content-length: ", 16) == 0))
90 else if ((
ep - cp > 12) && (strncasecmp(cp,
"Connection: ", 12) == 0))
92 else if ((
ep - cp > 4) && (strncmp(cp,
"\r\n\r\n", 4) == 0))
94 else if ((
ep - cp > 2) && (strncmp(cp,
"\n\n", 2) == 0))
104 XmlRpcUtil::error(
"XmlRpcServerConnection::readHeader: EOF while reading header");
113 XmlRpcUtil::error(
"XmlRpcServerConnection::readHeader: No Content-length specified");
130 if (
_header.find(
"HTTP/1.0") != std::string::npos) {
131 if (kp == 0 || strncasecmp(kp,
"keep-alive", 10) != 0)
134 if (kp != 0 && strncasecmp(kp,
"close", 5) == 0)
159 XmlRpcUtil::error(
"XmlRpcServerConnection::readRequest: EOF while reading request");
212 XmlRpcUtil::log(2,
"XmlRpcServerConnection::executeRequest: server calling method '%s'",
224 XmlRpcUtil::log(2,
"XmlRpcServerConnection::executeRequest: fault %s.",
259 if ( ! method)
return false;
261 method->
execute(params, result);
264 if ( ! result.
valid())
265 result = std::string();
281 int nc = params[0].
size();
284 for (
int i=0; i<
nc; ++i) {
287 ! params[0][i].hasMember(
PARAMS)) {
290 ": Invalid argument (expected a struct with members methodName and params)";
294 const std::string& methodName = params[0][i][
METHODNAME];
300 if ( !
executeMethod(methodName, methodParams, resultValue[0]) &&
304 result[i][
FAULTSTRING] = methodName +
": unknown method name";
307 result[i] = resultValue;
323 const char RESPONSE_1[] =
324 "<?xml version=\"1.0\"?>\r\n"
325 "<methodResponse><params><param>\r\n\t";
326 const char RESPONSE_2[] =
327 "\r\n</param></params></methodResponse>\r\n";
329 std::string body = RESPONSE_1 + resultXml + RESPONSE_2;
341 "HTTP/1.1 200 OK\r\n"
345 "Content-Type: text/xml\r\n"
349 sprintf(buffLen,
"%d\r\n\r\n", body.size());
351 return header + buffLen;
358 const char RESPONSE_1[] =
359 "<?xml version=\"1.0\"?>\r\n"
360 "<methodResponse><fault>\r\n\t";
361 const char RESPONSE_2[] =
362 "\r\n</fault></methodResponse>\r\n";
367 std::string body = RESPONSE_1 + faultStruct.
toXml() + RESPONSE_2;
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
@ ReadableEvent
data available to read
@ WritableEvent
connected/data can be written without blocking
int getCode() const
Return the error code.
const std::string & getMessage() const
Return the error message.
ServerConnectionState _connectionState
bool executeMethod(const std::string &methodName, XmlRpcValue ¶ms, XmlRpcValue &result)
std::string parseRequest(XmlRpcValue ¶ms)
void generateFaultResponse(std::string const &msg, int errorCode=-1)
void generateResponse(std::string const &resultXml)
static const std::string METHODNAME
std::string generateHeader(std::string const &body)
static const std::string PARAMS
static const char PARAMS_TAG[]
static const std::string FAULTSTRING
virtual ~XmlRpcServerConnection()
Destructor.
static const char PARAMS_ETAG[]
static const std::string FAULTCODE
virtual void executeRequest()
XmlRpcServerConnection(int fd, XmlRpcServer *server, bool deleteOnClose=false)
Constructor.
bool executeMulticall(const std::string &methodName, XmlRpcValue ¶ms, XmlRpcValue &result)
static const char METHODNAME_TAG[]
static const char PARAM_TAG[]
virtual unsigned handleEvent(unsigned eventType)
static const std::string SYSTEM_MULTICALL
static const char PARAM_ETAG[]
Abstract class representing a single RPC method.
virtual void execute(XmlRpcValue ¶ms, XmlRpcValue &result)=0
Execute the method. Subclasses must provide a definition for this method.
A class to handle XML RPC requests.
virtual void removeConnection(XmlRpcServerConnection *)
Remove a connection from the dispatcher.
XmlRpcServerMethod * findMethod(const std::string &name) const
Look up a method by name.
static bool nbWrite(int socket, std::string &s, int *bytesSoFar)
Write text to the specified socket. Returns false on error.
static bool nbRead(int socket, std::string &s, bool *eof)
Read text from the specified socket. Returns false on error.
static std::string getErrorMsg()
Returns message corresponding to last error.
An RPC source represents a file descriptor to monitor.
int getfd() const
Return the file descriptor being monitored.
static bool nextTagIs(const char *tag, std::string const &xml, int *offset)
static std::string parseTag(const char *tag, std::string const &xml, int *offset)
Returns contents between <tag> and </tag>, updates offset to char after </tag>
static void error(const char *fmt,...)
Dump error messages somewhere.
static bool findTag(const char *tag, std::string const &xml, int *offset)
Returns true if the tag is found and updates offset to the char after the tag.
static void log(int level, const char *fmt,...)
Dump messages somewhere.
RPC method arguments and results are represented by Values.
int size() const
Return the size for string, base64, array, and struct values.
bool valid() const
Return true if the value has been set to something.
std::string toXml() const
Encode the Value in xml.
void setSize(int size)
Specify the size for array values. Array values will grow beyond this size if needed.
Type const & getType() const
Return the type of the value stored.
const char XMLRPC_VERSION[]
Version identifier.