|
Fawkes API
Fawkes Development Version
|
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.
| 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 WebviewThread::init(), and XmlRpcThread::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::hex_unescape(), fawkes::WebRequestProcessor::handles_session_data(), fawkes::WebRequestProcessor::process_request(), fawkes::DynamicWebReply::size(), fawkes::DynamicWebReply::chunk_size(), fawkes::dynamic_reply_data_cb(), and fawkes::dynamic_reply_free_cb().
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().
| 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::WebPageReply::pack(), fawkes::StaticWebReply::pack(), fawkes::StaticWebReply::body_length(), fawkes::StaticWebReply::body(), fawkes::WebReply::headers(), and fawkes::WebReply::code().
| 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.