Web request dispatcher. More...
#include <request_dispatcher.h>
Public Member Functions | |
| WebRequestDispatcher (WebPageHeaderGenerator *headergen=0, WebPageFooterGenerator *footergen=0) | |
| Constructor. | |
| void | add_processor (const char *url_prefix, WebRequestProcessor *processor) |
| Add a request processor. | |
| void | remove_processor (const char *url_prefix) |
| Remove a request processor. | |
| int | queue_static_reply (struct MHD_Connection *connection, StaticWebReply *sreply) |
| Queue a static web reply. | |
| int | process_request (struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **session_data) |
| Process request callback for libmicrohttpd. | |
Static Public Member Functions | |
| static int | process_request_cb (void *callback_data, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **session_data) |
| Process request callback for libmicrohttpd. | |
Web request dispatcher.
Takes web request received via a webserver run by libmicrohttpd and dispatches pages to registered WebRequestProcessor instances or gives a 404 error if no processor was registered for the given base url.
Definition at line 42 of file request_dispatcher.h.
| fawkes::WebRequestDispatcher::WebRequestDispatcher | ( | WebPageHeaderGenerator * | headergen = 0, |
|
| WebPageFooterGenerator * | footergen = 0 | |||
| ) |
Constructor.
| headergen | page header generator | |
| footergen | page footer generator |
Definition at line 54 of file request_dispatcher.cpp.
| void fawkes::WebRequestDispatcher::add_processor | ( | const char * | url_prefix, | |
| WebRequestProcessor * | processor | |||
| ) |
Add a request processor.
| url_prefix | baseurl this processor should handle | |
| processor | processor for baseurl |
Definition at line 273 of file request_dispatcher.cpp.
Referenced by XmlRpcThread::init(), and WebviewThread::init().
| int fawkes::WebRequestDispatcher::process_request | ( | struct MHD_Connection * | connection, | |
| const char * | url, | |||
| const char * | method, | |||
| const char * | version, | |||
| const char * | upload_data, | |||
| size_t * | upload_data_size, | |||
| void ** | session_data | |||
| ) |
Process request callback for libmicrohttpd.
| connection | libmicrohttpd connection instance | |
| url | URL, may contain escape sequences | |
| method | HTTP method | |
| version | HTTP version | |
| upload_data | uploaded data | |
| upload_data_size | size of upload_data parameter | |
| session_data | session data pointer |
Definition at line 171 of file request_dispatcher.cpp.
References fawkes::DynamicWebReply::chunk_size(), fawkes::dynamic_reply_data_cb(), fawkes::dynamic_reply_free_cb(), fawkes::WebRequestProcessor::handles_session_data(), fawkes::hex_unescape(), fawkes::WebReply::HTTP_INTERNAL_SERVER_ERROR, fawkes::WebReply::HTTP_NOT_FOUND, fawkes::WebRequestProcessor::process_request(), queue_static_reply(), and fawkes::DynamicWebReply::size().
Referenced by process_request_cb().
| int fawkes::WebRequestDispatcher::process_request_cb | ( | void * | callback_data, | |
| struct MHD_Connection * | connection, | |||
| const char * | url, | |||
| const char * | method, | |||
| const char * | version, | |||
| const char * | upload_data, | |||
| size_t * | upload_data_size, | |||
| void ** | session_data | |||
| ) | [static] |
Process request callback for libmicrohttpd.
| callback_data | instance of WebRequestDispatcher to call | |
| connection | libmicrohttpd connection instance | |
| url | URL, may contain escape sequences | |
| method | HTTP method | |
| version | HTTP version | |
| upload_data | uploaded data | |
| upload_data_size | size of upload_data parameter | |
| session_data | session data pointer |
Definition at line 74 of file request_dispatcher.cpp.
References process_request().
Referenced by fawkes::WebServer::WebServer().
| int fawkes::WebRequestDispatcher::queue_static_reply | ( | struct MHD_Connection * | connection, | |
| StaticWebReply * | sreply | |||
| ) |
Queue a static web reply.
| connection | libmicrohttpd connection to queue response to | |
| sreply | static web reply to queue |
Definition at line 127 of file request_dispatcher.cpp.
References fawkes::StaticWebReply::body(), fawkes::StaticWebReply::body_length(), fawkes::WebReply::code(), fawkes::WebReply::headers(), fawkes::StaticWebReply::pack(), and fawkes::WebPageReply::pack().
Referenced by process_request().
| void fawkes::WebRequestDispatcher::remove_processor | ( | const char * | url_prefix | ) |
Remove a request processor.
| url_prefix | baseurl the processor handled |
Definition at line 288 of file request_dispatcher.cpp.
1.6.1