Fawkes API  Fawkes Development Version
request_processor.cpp
1 
2 /***************************************************************************
3  * request_processor.cpp - HTTP request processor
4  *
5  * Created: Mon Oct 13 22:02:25 2008
6  * Copyright 2006-2008 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 <webview/request_processor.h>
24 
25 #include <sys/types.h>
26 #include <sys/socket.h>
27 #include <stdint.h>
28 #include <cstdarg>
29 #include <microhttpd.h>
30 #include <cstring>
31 
32 namespace fawkes {
33 #if 0 /* just to make Emacs auto-indent happy */
34 }
35 #endif
36 
37 /** @class WebRequestProcessor <webview/request_processor.h>
38  * Abstract web request processor.
39  * Interface used to define web request processor that can be registered to
40  * the WebRequestDispatcher.
41  * @author Tim Niemueller
42  *
43  *
44  * @fn virtual WebReply * WebRequestProcessor::process_request(const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **session_data) = 0
45  * Process a request.
46  * @param url URL, may contain escape sequences
47  * @param method HTTP method
48  * @param version HTTP version
49  * @param upload_data uploaded data
50  * @param upload_data_size size of upload_data parameter
51  * @param session_data session data pointer
52  * @return a WebReply instance, more specifically either a DynamicWebReply or a StaticWebReply
53  * that is sent as reply, or NULL to cause a 404 (not found) error.
54  */
55 
56 /** Constructor.
57  * @param handles_session_data set to true, if you handle the session_data
58  * field passed into process_request() by yourself. The method will then be
59  * called multiple times. On the first iteration, you must set *session_data
60  * to a non-NULL value and return NULL. Only on the second call you produce
61  * the real reply.
62  */
63 WebRequestProcessor::WebRequestProcessor(bool handles_session_data)
64 {
65  __handles_session_data = handles_session_data;
66 }
67 
68 /** Virtual empty destructor. */
69 WebRequestProcessor::~WebRequestProcessor()
70 {
71 }
72 
73 
74 /** Check if processor handles session data by itself.
75  * Read constructor information for detailed information.
76  * @return true if the processor handles session data itself, false otherwise
77  */
78 bool
79 WebRequestProcessor::handles_session_data() const
80 {
81  return __handles_session_data;
82 }
83 
84 } // end namespace fawkes
Fawkes library namespace.