Fork 0

148 lines
4.9 KiB

#error Please include <lighttpd/base.h> instead of this file
typedef enum {
/* waiting for request headers */
/* all headers received, now handling them, set up input filters
* this state is set by the previous vrequest after VRS_WROTE_RESPONSE_HEADERS (or the main connection),
* and the handle_request function is called (which execute the action stack by default)
/* request headers handled, input filters ready; now content is accepted
* this state is set via handle_indirect (handle_direct skips to LI_VRS_HANDLE_RESPONSE_HEADERS
/* all response headers written, now set up output filters */
/* output filters ready, content can be written */
/* request done */
/* VRS_END, */
} liVRequestState;
typedef liHandlerResult (*liFilterHandlerCB)(liVRequest *vr, liFilter *f);
typedef void (*liFilterFreeCB)(liVRequest *vr, liFilter *f);
typedef liHandlerResult (*liVRequestHandlerCB)(liVRequest *vr);
typedef liHandlerResult (*liVRequestPluginHandlerCB)(liVRequest *vr, liPlugin *p);
struct liFilter {
liChunkQueue *in, *out;
liFilterHandlerCB handle_data;
liFilterFreeCB handle_free;
gpointer param;
struct liFilters {
GPtrArray *queue;
liChunkQueue *in, *out;
guint skip_ndx;
struct liVRequestRef {
gint refcount;
liVRequest *vr; /* This is only accesible by the worker thread the vrequest belongs to, and it may be NULL if the vrequest is already reset */
struct liVRequest {
liConnection *con;
liWorker *wrk;
liVRequestRef *ref;
liOptionValue *options;
liVRequestState state;
handle_response_headers, handle_response_body,
handle_response_error; /* this is _not_ for 500 - internal error */
GPtrArray *plugin_ctx;
liPlugin *backend;
liRequest request;
liPhysical physical;
liResponse response;
/* environment entries will be passed to the backends */
liEnvironment env;
/* -> vr_in -> filters_in -> in -> handle -> out -> filters_out -> vr_out -> */
gboolean cq_memory_limit_hit; /* stop feeding chunkqueues with memory chunks */
liFilters filters_in, filters_out;
liChunkQueue *vr_in, *vr_out;
liChunkQueue *in, *out;
liActionStack action_stack;
gboolean actions_wait_for_response;
gint queued;
GList job_queue_link;
GPtrArray *stat_cache_entries;
do { \
if (vr->state == LI_VRS_HANDLE_REQUEST_HEADERS) { \
VR_ERROR(vr, "%s", "Cannot wait for response headers as no backend handler found - fix your config"); \
} else if (vr->state < LI_VRS_HANDLE_RESPONSE_HEADERS) { \
} \
} while (0)
LI_API liVRequest* li_vrequest_new(liConnection *con, liVRequestHandlerCB handle_response_headers, liVRequestHandlerCB handle_response_body, liVRequestHandlerCB handle_response_error, liVRequestHandlerCB handle_request_headers);
LI_API void li_vrequest_free(liVRequest *vr);
LI_API void li_vrequest_reset(liVRequest *vr);
LI_API liVRequestRef* li_vrequest_acquire_ref(liVRequest *vr);
LI_API liVRequest* li_vrequest_release_ref(liVRequestRef *vr_ref);
LI_API void li_vrequest_add_filter_in(liVRequest *vr, liFilterHandlerCB handle_data, liFilterFreeCB handle_free, gpointer param);
LI_API void li_vrequest_add_filter_out(liVRequest *vr, liFilterHandlerCB handle_data, liFilterFreeCB handle_free, gpointer param);
/* Signals an internal error; handles the error in the _next_ loop */
LI_API void li_vrequest_error(liVRequest *vr);
LI_API void li_vrequest_backend_overloaded(liVRequest *vr);
LI_API void li_vrequest_backend_dead(liVRequest *vr);
LI_API void li_vrequest_backend_error(liVRequest *vr, liBackendError berror);
/* received all request headers */
LI_API void li_vrequest_handle_request_headers(liVRequest *vr);
/* received (partial) request content */
LI_API void li_vrequest_handle_request_body(liVRequest *vr);
/* received all response headers/status code - call once from your indirect handler */
LI_API void li_vrequest_handle_response_headers(liVRequest *vr);
/* received (partial) response content - call from your indirect handler */
LI_API void li_vrequest_handle_response_body(liVRequest *vr);
/* response completely ready */
LI_API gboolean li_vrequest_handle_direct(liVRequest *vr);
/* handle request over time */
LI_API gboolean li_vrequest_handle_indirect(liVRequest *vr, liPlugin *p);
LI_API gboolean li_vrequest_is_handled(liVRequest *vr);
LI_API void li_vrequest_state_machine(liVRequest *vr);
LI_API void li_vrequest_joblist_append(liVRequest *vr);
LI_API void li_vrequest_joblist_append_async(liVRequest *vr);
LI_API gboolean li_vrequest_stat(liVRequest *vr);
LI_API gboolean li_vrequest_redirect(liVRequest *vr, GString *uri);