23 #include "webview_reqproc.h" 24 #include <core/exception.h> 25 #include <logging/logger.h> 26 #include <webview/error_reply.h> 27 #include <webview_msgs/ProcessRequest.h> 50 std::string &srv_name)
54 __srv_name = srv_name;
55 __logcomp = std::string(
"ROSWebviewRP[") + srv_name +
"]";
57 __srv_client = nh->serviceClient<webview_msgs::ProcessRequest>(srv_name);
63 __srv_client.shutdown();
70 const char *upload_data,
71 size_t *upload_data_size,
74 logger->
log_debug(__logcomp.c_str(),
"Processing %s", url);
76 webview_msgs::ProcessRequest srv;
77 srv.request.url = url;
78 srv.request.method = method;
79 srv.request.version = version;
80 srv.request.upload_data =
81 std::vector<uint8_t>((uint8_t *)upload_data,
82 (uint8_t *)&upload_data[*upload_data_size]);
84 if (! __srv_client.exists()) {
86 "Service %s is no longer available",
89 }
else if (__srv_client.call(srv)) {
90 if (srv.response.code == WebReply::HTTP_OK) {
92 if (srv.response.wrap_in_page) {
101 std::vector<std::string>::iterator h;
102 for (h = srv.response.headers.begin(); h != srv.response.headers.end(); ++h)
114 "Execution of service %s failed: %s",
116 srv.response.error.c_str());
120 "Execution of service %s failed",
Fawkes library namespace.
ROSWebviewRequestProcessor(fawkes::LockPtr< ros::NodeHandle > nh, fawkes::Logger *logger, std::string &baseurl, std::string &srv_name)
Constructor.
void add_header(std::string header, std::string content)
Add a HTTP header.
virtual ~ROSWebviewRequestProcessor()
Destructor.
Base class for exceptions in Fawkes.
response_code_t
HTTP response code.
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
virtual fawkes::WebReply * process_request(const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **session_data)
Process a request.