WEBBY - the embedded web server with many faces / objects in plain C Snapshot
Classes | Typedefs | Functions
HTTP_FILTER

HTTP_FILTER - a filter implements a stage of processing the HTTP request / response. More...

Classes

struct  tagFILTER_CONTEXT
 structure is passed to filter function as argument. More...
union  RDATA
struct  tagHTTP_FILTER
 http filter definition More...

Typedefs

typedef struct tagFILTER_CONTEXT FILTER_CONTEXT
 structure is passed to filter function as argument.
typedef int(* HTTP_FILTER_INIT )(struct tagHTTP_FILTER *filter)
typedef int(* HTTP_FILTER_FREE )(struct tagHTTP_FILTER *filter)
typedef int(* HTTP_FILTER_REQUEST_HEADER_PARSED )(HTTP_REQUEST *request, FILTER_CONTEXT *context)
 filter callback: a http request header has been parsed, now the request header is passed through the filter chain.
typedef int(* HTTP_FILTER_REQUEST_DATA )(HTTP_REQUEST *request, void *data, size_t data_size, FILTER_CONTEXT *context)
 filter callback: a buffer that is part of the request data has been received.
typedef int(* HTTP_FILTER_REQUEST_COMPLETED )(HTTP_REQUEST *request, FILTER_CONTEXT *context)
 filter callback: the http request has been parsed completely, and all request data has already been processed.
typedef int(* HTTP_FILTER_RESPONSE_HEADER )(HTTP_RESPONSE *response, FILTER_CONTEXT *context)
 filter callback: a response header has now passed through the filter.
typedef int(* HTTP_FILTER_RESPONSE_DATA )(HTTP_RESPONSE *response, int is_chunk, RDATA rdata, FILTER_CONTEXT *context)
 filter callback: a buffer that is part of the response data has now passed through the filter
typedef int(* HTTP_FILTER_RESPONSE_COMPLETED )(HTTP_RESPONSE *response, FILTER_CONTEXT *context)
 filter callback: a http response has now passed completely through the filter, all response data has already been sent.
typedef int(* HTTP_FILTER_CONNECTION_CLOSE )(FILTER_CONTEXT *context)
 filter callback: called when a connection has been closed, the filter should free the connection context data, if any of it has been allocated.
typedef struct tagHTTP_FILTER HTTP_FILTER
 http filter definition

Functions

M_INLINE int call_next_filter_request_header_parsed (HTTP_REQUEST *request, FILTER_CONTEXT *context)
 called by implementaiton of HTTP_FILTER_REQUEST_HEADER_PARSED filter callback, calls the next filter in the chain
M_INLINE int call_next_filter_request_data (HTTP_REQUEST *request, void *data, size_t data_size, FILTER_CONTEXT *context)
 called by implementaiton of HTTP_FILTER_REQUEST_DATA filter callback, calls the next filter in the chain
M_INLINE int call_next_filter_request_completed (HTTP_REQUEST *request, FILTER_CONTEXT *context)
 called by implementaiton of HTTP_FILTER_REQUEST_COMPLETED filter callback, calls the next filter in the chain
M_INLINE int call_next_filter_response_header (HTTP_RESPONSE *response, FILTER_CONTEXT *context)
 called by implementaiton of HTTP_FILTER_RESPONSE_HEADER filter callback, calls the next filter in the chain
M_INLINE int call_next_filter_response_data (HTTP_RESPONSE *response, int is_chunk, RDATA rdata, FILTER_CONTEXT *context)
 called by implementaiton of HTTP_FILTER_RESPONSE_DATA filter callback, calls the next filter in the chain
M_INLINE int call_next_filter_response_completed (HTTP_RESPONSE *response, FILTER_CONTEXT *context)
 called by implementaiton of HTTP_FILTER_RESPONSE_COMPLETED filter callback, calls the next filter in the chain

Detailed Description

HTTP_FILTER - a filter implements a stage of processing the HTTP request / response.

A filter can modify either one of the following aspects, as they are processed.


Typedef Documentation

structure is passed to filter function as argument.

typedef struct tagHTTP_FILTER HTTP_FILTER

http filter definition

typedef int(* HTTP_FILTER_CONNECTION_CLOSE)(FILTER_CONTEXT *context)

filter callback: called when a connection has been closed, the filter should free the connection context data, if any of it has been allocated.

Parameters:
context- filter context, we need it to call the next filter.

Definition at line 132 of file webby.h.

typedef int(* HTTP_FILTER_FREE)(struct tagHTTP_FILTER *filter)

Definition at line 46 of file webby.h.

typedef int(* HTTP_FILTER_INIT)(struct tagHTTP_FILTER *filter)

Definition at line 43 of file webby.h.

typedef int(* HTTP_FILTER_REQUEST_COMPLETED)(HTTP_REQUEST *request, FILTER_CONTEXT *context)

filter callback: the http request has been parsed completely, and all request data has already been processed.

request - the http request header.

Parameters:
context- filter context, we need it to call the next filter.

Definition at line 73 of file webby.h.

typedef int(* HTTP_FILTER_REQUEST_DATA)(HTTP_REQUEST *request, void *data, size_t data_size, FILTER_CONTEXT *context)

filter callback: a buffer that is part of the request data has been received.

Parameters:
request- the http request header
data- request data, if request data is chunked then this is after parsing of chunk (no chunk headers included)
data_size- size of request data
context- filter context, we need it to call the next filter.

Definition at line 65 of file webby.h.

typedef int(* HTTP_FILTER_REQUEST_HEADER_PARSED)(HTTP_REQUEST *request, FILTER_CONTEXT *context)

filter callback: a http request header has been parsed, now the request header is passed through the filter chain.

Parameters:
request- the http request header
context- filter context, we need it to call the next filter.

Definition at line 55 of file webby.h.

typedef int(* HTTP_FILTER_RESPONSE_COMPLETED)(HTTP_RESPONSE *response, FILTER_CONTEXT *context)

filter callback: a http response has now passed completely through the filter, all response data has already been sent.

response - the http response header.

Parameters:
context- filter context, we need it to call the next filter.

Definition at line 125 of file webby.h.

typedef int(* HTTP_FILTER_RESPONSE_DATA)(HTTP_RESPONSE *response, int is_chunk, RDATA rdata, FILTER_CONTEXT *context)

filter callback: a buffer that is part of the response data has now passed through the filter

There are two situations - the response uses 'chunks', the response does not use chunks.

If the response is chunked then a buffer object (BF) is used, which reserves space for chunk header before the start of the buffer.

The case of chunks: is_chunk != 0 rdata.chunk.bf - the chunk buffer (zero for the last chunk) rdata.chunk.chunk_no - the number of the chunk (starts with zero).

The case of no chunks: rdata.no_chunk.data - response data rdata.no_chunk.data_size - size of response data.

response - the http response header. is_chunk - not zero if response is chunked rdata - union that holds data for both chunked and not chunked case;

Parameters:
context- filter context, we need it to call the next filter.

Definition at line 117 of file webby.h.

typedef int(* HTTP_FILTER_RESPONSE_HEADER)(HTTP_RESPONSE *response, FILTER_CONTEXT *context)

filter callback: a response header has now passed through the filter.

response - the http response header.

Parameters:
context- filter context, we need it to call the next filter.

Definition at line 81 of file webby.h.


Function Documentation

M_INLINE int call_next_filter_request_completed ( HTTP_REQUEST *  request,
FILTER_CONTEXT context 
)

called by implementaiton of HTTP_FILTER_REQUEST_COMPLETED filter callback, calls the next filter in the chain

Definition at line 186 of file webby.h.

{
  FILTER_CONTEXT *next = context +  context->next_request_filter_idx;
  if (next->filter == 0) {
    return 0;
  }
  return next->filter->on_request_completed( request,  next );
}
M_INLINE int call_next_filter_request_data ( HTTP_REQUEST *  request,
void *  data,
size_t  data_size,
FILTER_CONTEXT context 
)

called by implementaiton of HTTP_FILTER_REQUEST_DATA filter callback, calls the next filter in the chain

Definition at line 174 of file webby.h.

{
  FILTER_CONTEXT *next = context + context->next_request_filter_idx;
  if (next->filter == 0) {
    return 0;
  }
  return next->filter->on_request_data( request, data, data_size, next );
}
M_INLINE int call_next_filter_request_header_parsed ( HTTP_REQUEST *  request,
FILTER_CONTEXT context 
)

called by implementaiton of HTTP_FILTER_REQUEST_HEADER_PARSED filter callback, calls the next filter in the chain

Definition at line 162 of file webby.h.

{
  FILTER_CONTEXT *next = context + context->next_request_filter_idx;
  if (next->filter == 0) {
    return 0;
  }
  return next->filter->on_request_header_parsed( request, next );
}
M_INLINE int call_next_filter_response_completed ( HTTP_RESPONSE *  response,
FILTER_CONTEXT context 
)

called by implementaiton of HTTP_FILTER_RESPONSE_COMPLETED filter callback, calls the next filter in the chain

Definition at line 222 of file webby.h.

{
  FILTER_CONTEXT *next = context -  context->next_response_filter_idx;
  if (next->filter == 0) {
    return 0;
  }
  return next->filter->on_response_completed( response, next );
}
M_INLINE int call_next_filter_response_data ( HTTP_RESPONSE *  response,
int  is_chunk,
RDATA  rdata,
FILTER_CONTEXT context 
)

called by implementaiton of HTTP_FILTER_RESPONSE_DATA filter callback, calls the next filter in the chain

Definition at line 210 of file webby.h.

{
  FILTER_CONTEXT *next = context -  context->next_response_filter_idx;
  if (next->filter == 0) {
    return 0;
  }
  return next->filter->on_response_data( response, is_chunk, rdata, next );
}
M_INLINE int call_next_filter_response_header ( HTTP_RESPONSE *  response,
FILTER_CONTEXT context 
)

called by implementaiton of HTTP_FILTER_RESPONSE_HEADER filter callback, calls the next filter in the chain

Definition at line 198 of file webby.h.

{
  FILTER_CONTEXT *next = context - context->next_response_filter_idx;
  if (next->filter == 0) {
    return 0;
  }
  return next->filter->on_response_header( response, next );
}