Fawkes API Fawkes Development Version

request_processor.cpp

00001 
00002 /***************************************************************************
00003  *  request_processor.cpp - HTTP request processor
00004  *
00005  *  Created: Mon Oct 13 22:02:25 2008
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #include <webview/request_processor.h>
00024 
00025 #include <sys/types.h>
00026 #include <sys/socket.h>
00027 #include <stdint.h>
00028 #include <cstdarg>
00029 #include <microhttpd.h>
00030 #include <cstring>
00031 
00032 namespace fawkes {
00033 #if 0 /* just to make Emacs auto-indent happy */
00034 }
00035 #endif
00036 
00037 /** @class WebRequestProcessor <webview/request_processor.h>
00038  * Abstract web request processor.
00039  * Interface used to define web request processor that can be registered to
00040  * the WebRequestDispatcher.
00041  * @author Tim Niemueller
00042  *
00043  *
00044  * @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
00045  * Process a request.
00046  * @param url URL, may contain escape sequences
00047  * @param method HTTP method
00048  * @param version HTTP version
00049  * @param upload_data uploaded data
00050  * @param upload_data_size size of upload_data parameter
00051  * @param session_data session data pointer
00052  * @return a WebReply instance, more specifically either a DynamicWebReply or a StaticWebReply
00053  * that is sent as reply, or NULL to cause a 404 (not found) error.
00054  */
00055 
00056 /** Constructor.
00057  * @param handles_session_data set to true, if you handle the session_data
00058  * field passed into process_request() by yourself. The method will then be
00059  * called multiple times. On the first iteration, you must set *session_data
00060  * to a non-NULL value and return NULL. Only on the second call you produce
00061  * the real reply.
00062  */
00063 WebRequestProcessor::WebRequestProcessor(bool handles_session_data)
00064 {
00065   __handles_session_data = handles_session_data;
00066 }
00067 
00068 /** Virtual empty destructor. */
00069 WebRequestProcessor::~WebRequestProcessor()
00070 {
00071 }
00072 
00073 
00074 /** Check if processor handles session data by itself.
00075  * Read constructor information for detailed information.
00076  * @return true if the processor handles session data itself, false otherwise
00077  */
00078 bool
00079 WebRequestProcessor::handles_session_data() const
00080 {
00081   return __handles_session_data;
00082 }
00083 
00084 } // end namespace fawkes
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends