Fawkes API
Fawkes Development Version
xmlrpc_processor.cpp
1
2
/***************************************************************************
3
* xmlrpc_processor.cpp - XML-RPC processor
4
*
5
* Created: Sun Aug 30 19:39:31 2009
6
* Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include "xmlrpc_processor.h"
24
25
#include <logging/logger.h>
26
#include <webview/error_reply.h>
27
#include <webview/page_reply.h>
28
#include <webview/request.h>
29
30
#include <cstring>
31
#include <xmlrpc-c/registry.hpp>
32
33
using namespace
fawkes
;
34
35
// accept up to 512KB as request
36
#define MAX_REQUEST_LENGTH (1024 * 512)
37
38
/** @class XmlRpcRequestProcessor "xmlrpc_processor.h"
39
* XML-RPC web request processor.
40
* Process web requests and pass them to the XML-RPC processor.
41
* @author Tim Niemueller
42
*/
43
44
/** Constructor.
45
* @param logger logger to report problems
46
*/
47
XmlRpcRequestProcessor::XmlRpcRequestProcessor
(
fawkes::Logger
*logger)
48
{
49
logger_ = logger;
50
xmlrpc_registry_.reset(
new
xmlrpc_c::registry);
51
}
52
53
/** Destructor. */
54
XmlRpcRequestProcessor::~XmlRpcRequestProcessor
()
55
{
56
xmlrpc_registry_.reset();
57
}
58
59
/** Get XML-RPC registry.
60
* @return XML-RPC registry
61
*/
62
std::shared_ptr<xmlrpc_c::registry>
63
XmlRpcRequestProcessor::registry
()
64
{
65
return
xmlrpc_registry_;
66
}
67
68
/** Process request.
69
* @param request incoming request
70
* @return web reply
71
*/
72
WebReply
*
73
XmlRpcRequestProcessor::process_request
(
const
fawkes::WebRequest
*request)
74
{
75
if
(request->
method
() !=
WebRequest::METHOD_POST
) {
76
return
new
WebErrorPageReply
(
WebErrorPageReply::HTTP_METHOD_NOT_ALLOWED
);
77
}
else
{
78
std::string response;
79
xmlrpc_registry_->processCall(request->
body
(), &response);
80
//logger_->log_debug("XmlRpcRequestProcessor", "Call: %s reponse: %s",
81
// request->raw_post_data().c_str(), response.c_str());
82
return
new
StaticWebReply
(
WebReply::HTTP_OK
, response);
83
}
84
}
fawkes::WebRequest
Web request meta data carrier.
Definition:
request.h:42
XmlRpcRequestProcessor::process_request
fawkes::WebReply * process_request(const fawkes::WebRequest *request)
Process request.
Definition:
xmlrpc_processor.cpp:73
fawkes::WebReply::HTTP_OK
@ HTTP_OK
OK.
Definition:
reply.h:42
fawkes::Logger
Interface for logging.
Definition:
logger.h:42
fawkes
Fawkes library namespace.
XmlRpcRequestProcessor::~XmlRpcRequestProcessor
~XmlRpcRequestProcessor()
Destructor.
Definition:
xmlrpc_processor.cpp:54
fawkes::WebRequest::METHOD_POST
@ METHOD_POST
POST.
Definition:
request.h:53
XmlRpcRequestProcessor::XmlRpcRequestProcessor
XmlRpcRequestProcessor(fawkes::Logger *logger)
Constructor.
Definition:
xmlrpc_processor.cpp:47
fawkes::WebRequest::body
const std::string & body() const
Get body of request.
Definition:
request.h:325
fawkes::WebErrorPageReply
Static error page reply.
Definition:
error_reply.h:31
fawkes::WebReply::HTTP_METHOD_NOT_ALLOWED
@ HTTP_METHOD_NOT_ALLOWED
METHOD_NOT_ALLOWED.
Definition:
reply.h:65
fawkes::StaticWebReply
Static web reply.
Definition:
reply.h:136
fawkes::WebRequest::method
Method method() const
Get HTTP transfer method.
Definition:
request.h:84
XmlRpcRequestProcessor::registry
std::shared_ptr< xmlrpc_c::registry > registry()
Get XML-RPC registry.
Definition:
xmlrpc_processor.cpp:63
fawkes::WebReply
Basic web reply.
Definition:
reply.h:34
src
plugins
xmlrpc
xmlrpc_processor.cpp
Generated by
1.8.20