Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
FastCGI Tools
Collaboration diagram for FastCGI Tools:

Data Structures

struct  ap_fcgi_header
 A structure that represents the fixed header fields at the beginning of a "FastCGI record" (i.e., the data prior to content data and padding). More...
 
struct  ap_fcgi_begin_request_body
 This represents the content data of the FastCGI record when the type is AP_FCGI_BEGIN_REQUEST. More...
 

Macros

#define AP_FCGI_HEADER_LEN   8
 
#define AP_FCGI_MAX_CONTENT_LEN   65535
 
#define AP_FCGI_VERSION_1   1
 
#define AP_FCGI_BEGIN_REQUEST   1
 
#define AP_FCGI_ABORT_REQUEST   2
 
#define AP_FCGI_END_REQUEST   3
 
#define AP_FCGI_PARAMS   4
 
#define AP_FCGI_STDIN   5
 
#define AP_FCGI_STDOUT   6
 
#define AP_FCGI_STDERR   7
 
#define AP_FCGI_DATA   8
 
#define AP_FCGI_GET_VALUES   9
 
#define AP_FCGI_GET_VALUES_RESULT   10
 
#define AP_FCGI_UNKNOWN_TYPE   11
 
#define AP_FCGI_MAXTYPE   (AP_FCGI_UNKNOWN_TYPE)
 
#define AP_FCGI_HDR_VERSION_OFFSET   0
 
#define AP_FCGI_HDR_TYPE_OFFSET   1
 
#define AP_FCGI_HDR_REQUEST_ID_B1_OFFSET   2
 
#define AP_FCGI_HDR_REQUEST_ID_B0_OFFSET   3
 
#define AP_FCGI_HDR_CONTENT_LEN_B1_OFFSET   4
 
#define AP_FCGI_HDR_CONTENT_LEN_B0_OFFSET   5
 
#define AP_FCGI_HDR_PADDING_LEN_OFFSET   6
 
#define AP_FCGI_HDR_RESERVED_OFFSET   7
 
#define AP_FCGI_RESPONDER   1
 
#define AP_FCGI_AUTHORIZER   2
 
#define AP_FCGI_FILTER   3
 
#define AP_FCGI_KEEP_CONN   1 /* otherwise the application closes */
 
#define AP_FCGI_BRB_ROLEB1_OFFSET   0
 
#define AP_FCGI_BRB_ROLEB0_OFFSET   1
 
#define AP_FCGI_BRB_FLAGS_OFFSET   2
 
#define AP_FCGI_BRB_RESERVED0_OFFSET   3
 
#define AP_FCGI_BRB_RESERVED1_OFFSET   4
 
#define AP_FCGI_BRB_RESERVED2_OFFSET   5
 
#define AP_FCGI_BRB_RESERVED3_OFFSET   6
 
#define AP_FCGI_BRB_RESERVED4_OFFSET   7
 
#define AP_FCGI_RESPONDER_STR   "RESPONDER"
 
#define AP_FCGI_AUTHORIZER_STR   "AUTHORIZER"
 
#define AP_FCGI_FILTER_STR   "FILTER"
 
#define AP_FCGI_APACHE_ROLE_AUTHENTICATOR_STR   "AUTHENTICATOR"
 
#define AP_FCGI_APACHE_ROLE_AUTHORIZER_STR   "AUTHORIZER"
 
#define AP_FCGI_APACHE_ROLE_ACCESS_CHECKER_STR   "ACCESS_CHECKER"
 

Functions

void ap_fcgi_header_to_array (ap_fcgi_header *h, unsigned char a[])
 
void ap_fcgi_header_from_array (ap_fcgi_header *h, unsigned char a[])
 
void ap_fcgi_header_fields_from_array (unsigned char *version, unsigned char *type, apr_uint16_t *request_id, apr_uint16_t *content_len, unsigned char *padding_len, unsigned char a[])
 
void ap_fcgi_begin_request_body_to_array (ap_fcgi_begin_request_body *h, unsigned char a[])
 
void ap_fcgi_fill_in_header (ap_fcgi_header *header, unsigned char type, apr_uint16_t request_id, apr_uint16_t content_len, unsigned char padding_len)
 
void ap_fcgi_fill_in_request_body (ap_fcgi_begin_request_body *brb, int role, unsigned char flags)
 
apr_size_t ap_fcgi_encoded_env_len (apr_table_t *env, apr_size_t maxlen, int *starting_elem)
 
apr_status_t ap_fcgi_encode_env (request_rec *r, apr_table_t *env, void *buffer, apr_size_t buflen, int *starting_elem)
 

Detailed Description

Macro Definition Documentation

#define AP_FCGI_ABORT_REQUEST   2
#define AP_FCGI_APACHE_ROLE_ACCESS_CHECKER_STR   "ACCESS_CHECKER"
#define AP_FCGI_APACHE_ROLE_AUTHENTICATOR_STR   "AUTHENTICATOR"

FastCGI implementations that implement the AUTHORIZER role for Apache httpd and allow the application to participate in any of the Apache httpd AAA phases typically set the variable FCGI_APACHE_ROLE to one of these strings to indicate the specific AAA phase.

#define AP_FCGI_APACHE_ROLE_AUTHORIZER_STR   "AUTHORIZER"
#define AP_FCGI_AUTHORIZER   2
#define AP_FCGI_AUTHORIZER_STR   "AUTHORIZER"
#define AP_FCGI_BEGIN_REQUEST   1

Possible values for the type field of ap_fcgi_header

#define AP_FCGI_BRB_FLAGS_OFFSET   2
#define AP_FCGI_BRB_RESERVED0_OFFSET   3
#define AP_FCGI_BRB_RESERVED1_OFFSET   4
#define AP_FCGI_BRB_RESERVED2_OFFSET   5
#define AP_FCGI_BRB_RESERVED3_OFFSET   6
#define AP_FCGI_BRB_RESERVED4_OFFSET   7
#define AP_FCGI_BRB_ROLEB0_OFFSET   1
#define AP_FCGI_BRB_ROLEB1_OFFSET   0

Offsets of the various fields of ap_fcgi_begin_request_body

#define AP_FCGI_DATA   8
#define AP_FCGI_END_REQUEST   3
#define AP_FCGI_FILTER   3
#define AP_FCGI_FILTER_STR   "FILTER"
#define AP_FCGI_GET_VALUES   9
#define AP_FCGI_GET_VALUES_RESULT   10
#define AP_FCGI_HDR_CONTENT_LEN_B0_OFFSET   5
#define AP_FCGI_HDR_CONTENT_LEN_B1_OFFSET   4
#define AP_FCGI_HDR_PADDING_LEN_OFFSET   6
#define AP_FCGI_HDR_REQUEST_ID_B0_OFFSET   3
#define AP_FCGI_HDR_REQUEST_ID_B1_OFFSET   2
#define AP_FCGI_HDR_RESERVED_OFFSET   7
#define AP_FCGI_HDR_TYPE_OFFSET   1
#define AP_FCGI_HDR_VERSION_OFFSET   0

Offsets of the various fields of ap_fcgi_header

#define AP_FCGI_HEADER_LEN   8
#define AP_FCGI_KEEP_CONN   1 /* otherwise the application closes */
#define AP_FCGI_MAX_CONTENT_LEN   65535
#define AP_FCGI_MAXTYPE   (AP_FCGI_UNKNOWN_TYPE)
#define AP_FCGI_PARAMS   4
#define AP_FCGI_RESPONDER   1
#define AP_FCGI_RESPONDER_STR   "RESPONDER"

String forms for the value of the FCGI_ROLE envvar

#define AP_FCGI_STDERR   7
#define AP_FCGI_STDIN   5
#define AP_FCGI_STDOUT   6
#define AP_FCGI_UNKNOWN_TYPE   11
#define AP_FCGI_VERSION_1   1

Possible values for the version field of ap_fcgi_header

Function Documentation

void ap_fcgi_begin_request_body_to_array ( ap_fcgi_begin_request_body h,
unsigned char  a[] 
)

Pack ap_fcgi_begin_request_body

Parameters
hThe begin-request body to read from
aThe array to write to, of size AP_FCGI_HEADER_LEN
apr_status_t ap_fcgi_encode_env ( request_rec r,
apr_table_t env,
void buffer,
apr_size_t  buflen,
int starting_elem 
)

Encode the next portion of the provided environment table using a buffer previously allocated.

Parameters
rThe request, for logging
envThe environment table
bufferA buffer to contain the encoded environment table
buflenThe length of the buffer, previously computed by ap_fcgi_encoded_env_len().
starting_elemOn input, the next element of the table array to process in this FastCGI record. On output, the next element to process on the next FastCGI record.
Returns
APR_SUCCESS if a section could be encoded or APR_ENOSPC otherwise.
Note
The output starting_elem from ap_fcgi_encoded_env_len shouldn't be used as input to ap_fcgi_encode_env when building the same FastCGI record.
apr_size_t ap_fcgi_encoded_env_len ( apr_table_t env,
apr_size_t  maxlen,
int starting_elem 
)

Compute the buffer size needed to encode the next portion of the provided environment table.

Parameters
envThe environment table
maxlenThe maximum buffer size allowable, capped at AP_FCGI_MAX_CONTENT_LEN.
starting_elemOn input, the next element of the table array to process in this FastCGI record. On output, the next element to process on the next FastCGI record.
Returns
Size of buffer needed to encode the next part, or 0 if no more can be encoded. When 0 is returned: If starting_elem has reached the end of the table array, all has been encoded; otherwise, the next envvar can't be encoded within the specified limit.
Note
If an envvar can't be encoded within the specified limit, the caller can log a warning and increment starting_elem and try again or increase the limit or fail, as appropriate for the module.
void ap_fcgi_fill_in_header ( ap_fcgi_header header,
unsigned char  type,
apr_uint16_t  request_id,
apr_uint16_t  content_len,
unsigned char  padding_len 
)

Fill in a FastCGI request header with the required field values.

Parameters
headerThe header to fill in
typeThe type of record
request_idThe request id
content_lenThe amount of content which follows the header
padding_lenThe amount of padding which follows the content

The header array must be at least AP_FCGI_HEADER_LEN bytes long.

void ap_fcgi_fill_in_request_body ( ap_fcgi_begin_request_body brb,
int  role,
unsigned char  flags 
)

Fill in a FastCGI begin request body with the required field values.

Parameters
brbThe begin-request-body to fill in
roleAP_FCGI_RESPONDER or other roles
flags0 or a combination of flags like AP_FCGI_KEEP_CONN
void ap_fcgi_header_fields_from_array ( unsigned char *  version,
unsigned char *  type,
apr_uint16_t request_id,
apr_uint16_t content_len,
unsigned char *  padding_len,
unsigned char  a[] 
)

Unpack header of FastCGI record into individual fields

Parameters
versionThe version, on output
typeThe type, on output
request_idThe request id, on output
content_lenThe content length, on output
padding_lenThe amount of padding following the content, on output
aThe array to read from, of size AP_FCGI_HEADER_LEN
void ap_fcgi_header_from_array ( ap_fcgi_header h,
unsigned char  a[] 
)

Unpack header of FastCGI record into ap_fcgi_header

Parameters
hThe header to write to
aThe array to read from, of size AP_FCGI_HEADER_LEN
void ap_fcgi_header_to_array ( ap_fcgi_header h,
unsigned char  a[] 
)

Pack ap_fcgi_header

Parameters
hThe header to read from
aThe array to write to, of size AP_FCGI_HEADER_LEN