Go to the source code of this file.
Defines | |
#define | REQUEST 1 |
#define | RESPONSE 2 |
#define | HEADER 3 |
#define | PARAM 4 |
Functions | |
void * | http_processor (void *wrapper) |
Process a HTTP request. | |
void | add_Impl (void *doGetFunc, void *doPostFunc) |
Callback for implementors of cervlet functions. | |
void | send_error (HttpResponse res, int code, char *msg) |
Send an error message. | |
void | send_redirect (HttpResponse res, char *location) |
Sends a temporary redirect response to the client using the specified redirect Location URL. | |
void | out_print (HttpResponse res, const char *format,...) |
Prints a string into the given HttpResponse output buffer. | |
void | destroy_wrapper (RequestWrapper w) |
Free a RequestWrapper object. | |
void | set_header (HttpResponse res, char *name, char *value) |
Adds a response header with the given name and value. | |
void | set_status (HttpResponse res, int code, char *msg) |
Sets the status code for the response. | |
void | set_content_type (HttpResponse res, char *mime) |
Set the response content-type. | |
char * | get_header (HttpRequest req, const char *name) |
Returns the value of the specified header. | |
char * | get_parameter (HttpRequest req, const char *name) |
Returns the value of the specified parameter. | |
char * | get_headers (HttpResponse res) |
Returns a string containing all (extra) headers found in the response. | |
char * | get_status_string (int status) |
Lookup the corresponding HTTP status string for the given status code. | |
Variables | |
ssl_server_connection * | mySSLServerConnection |
This Processor delegates the actual handling of the request and reponse to so called cervlets, which must implement two methods; doGet and doPost. We call them cervlets because they are small C-modules closely resembling Java Servlets.
NOTES This Processor is command oriented and if a second slash '/' is found in the URL it's asumed to be the PATHINFO. In other words this processor perceive an URL as:
/COMMAND?args/PATHINFO
The doGet/doPost routines act's on the COMMAND. See the cervlet.c code in this dir. for an example.
2) This design is based on the Java Servlet API Framework, and to some extent; the Jakarta Catelina servlet engine by the very talented Craig R. McClanahan and others.
Definition in file processor.c.
|
Definition at line 53 of file processor.c. |
|
Definition at line 54 of file processor.c. |
|
Definition at line 51 of file processor.c. |
|
Definition at line 52 of file processor.c. |
|
Callback for implementors of cervlet functions.
Definition at line 149 of file processor.c. References ServiceImpl::doGet, ServiceImpl::doPost, and Impl. Referenced by init_service(). |
|
Free a RequestWrapper object.
Definition at line 303 of file processor.c. References close_accepted_ssl_socket(), close_socket(), myrun::httpdssl, requestwrapper::inetaddr, inetaddress::local_host, mySSLServerConnection, inetaddress::remote_host, Run, requestwrapper::socket, and requestwrapper::ssl. Referenced by http_processor(), and start_httpd(). |
|
Returns the value of the specified header.
Definition at line 406 of file processor.c. References request::headers, entry::name, entry::next, entry::value, and xstrdup(). |
|
Returns a string containing all (extra) headers found in the response. The headers are newline separated in the returned string.
Definition at line 457 of file processor.c. References response::headers, entry::name, entry::next, RES_STRLEN, entry::value, and xstrdup(). |
|
Returns the value of the specified parameter.
Definition at line 431 of file processor.c. References entry::name, entry::next, request::params, entry::value, and xstrdup(). |
|
|
Process a HTTP request. This is done by dispatching to the service function. Before the dispatch, an alarm clock is setup for handling request timeout.
Definition at line 123 of file processor.c. References destroy_wrapper(), SC_REQUEST_TIMEOUT, and requestwrapper::socket. Referenced by start_httpd(). |
|
Prints a string into the given HttpResponse output buffer. The actual response to the client is done in the service function, which will call the private function send_response. Cervlets should use this function (i.e. out_print) for sending a response, and never use the HttpResponse outputstream directly. Despite the above warning, IF the HttpResponse.outputstream was used directly by a cervlet THEN the cervlet MUST set the is_committed flag in the HttpResponse object and is responsible for sending all HTTP headers and content by itself.
Definition at line 217 of file processor.c. References response::bufsize, response::bufused, log(), response::outputbuffer, RES_STRLEN, xmalloc(), and xresize(). Referenced by send_error(). |
|
Send an error message.
Definition at line 166 of file processor.c. References get_status_string(), out_print(), SERVER_URL, set_content_type(), and set_status(). |
|
Sends a temporary redirect response to the client using the specified redirect Location URL. The url must be absolute.
Definition at line 192 of file processor.c. References get_status_string(), SC_MOVED_TEMPORARILY, set_header(), and set_status(). |
|
Set the response content-type.
Definition at line 393 of file processor.c. References set_header(). Referenced by send_error(). |
|
Adds a response header with the given name and value. If the header had already been set the new value overwrites the previous one.
Definition at line 338 of file processor.c. References response::headers, entry::name, NEW, entry::next, entry::value, and xstrdup(). Referenced by send_redirect(), and set_content_type(). |
|
Sets the status code for the response.
Definition at line 379 of file processor.c. References response::status, response::status_msg, and xstrdup(). Referenced by send_error(), and send_redirect(). |
|
Definition at line 57 of file processor.c. Referenced by destroy_wrapper(), start_httpd(), and stop_httpd(). |