c-icap-doc  0.1
Data Structures | Typedefs | Functions
Services API


Services related API. More...

Data Structures

struct  ci_service_module
 
Is the structure which implements a service More...
 

Typedefs

typedef struct ci_service_xdata ci_service_xdata_t
 
Stores required data and settings for a service
 

Functions

void ci_service_set_istag (ci_service_xdata_t *srv_xdata, const char *istag)
 
Sets the ISTAG for the service. More...
 
void ci_service_set_xopts (ci_service_xdata_t *srv_xdata, uint64_t xopts)
 
Sets the service x-headers mask which defines the X-Headers supported by the service.The c-icap server will advertise these headers in options responses. More...
 
void ci_service_add_xopts (ci_service_xdata_t *srv_xdata, uint64_t xopts)
 
it is similar to the function ci_service_set_xopts but just adds (not sets) the X-Headers defined by the xopts parameter to the existing x-headers mask of service.
 
void ci_service_set_transfer_preview (ci_service_xdata_t *srv_xdata, const char *preview)
 
Set the list of file extensions that should previewed by the service. More...
 
void ci_service_set_transfer_ignore (ci_service_xdata_t *srv_xdata, const char *ignore)
 
Set the list of file extensions that should NOT be send for this service. More...
 
void ci_service_set_transfer_complete (ci_service_xdata_t *srv_xdata, const char *complete)
 
Set the list of file extensions that should be send in their entirety (without preview) to this service. More...
 
void ci_service_set_preview (ci_service_xdata_t *srv_xdata, int preview)
 Sets the maximum preview size supported by this service. More...
 
void ci_service_enable_204 (ci_service_xdata_t *srv_xdata)
 Enable the allow 204 responses for this service. More...
 
void ci_service_enable_206 (ci_service_xdata_t *srv_xdata)
 Enable the Partial Content 206 responses for this service. More...
 
void ci_service_set_max_connections (ci_service_xdata_t *srv_xdata, int max_connections)
 Sets the maximum connection should opened by icap client to the c-icap for this service. More...
 
void ci_service_set_options_ttl (ci_service_xdata_t *srv_xdata, int ttl)
 Sets the Options ttl for this service. More...
 
void ci_service_add_option_handler (ci_service_xdata_t *srv_xdata, const char *name, int(*handler)(struct ci_request *))
 Add a service handler for the service. More...
 

Detailed Description


Services related API.

For detailed information about implementing a service look the documentation of struct ci_service_module

Function Documentation

◆ ci_service_add_option_handler()

void ci_service_add_option_handler ( ci_service_xdata_t srv_xdata,
const char *  name,
int(*)(struct ci_request *)  handler 
)

Add a service handler for the service.

Normally this function called in ci_service_module::mod_init_service() or ci_service_module::mod_post_init_service() function. The options handlers are running when the service receives an OPTIONS request to check for service health. They can add ICAP headers to the OPTIONS response and must return CI_OK on success, or CI_ERROR on failure. If one or more handlers failed the c-icap will produce a "500 Server Error" response.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
namea name for the handler, used for debuging reasons
handlerthe handler

◆ ci_service_enable_204()

void ci_service_enable_204 ( ci_service_xdata_t srv_xdata)

Enable the allow 204 responses for this service.

The service will supports the allow 204 responses if the icap client support it too.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
Examples:
services/echo/srv_echo.c.

◆ ci_service_enable_206()

void ci_service_enable_206 ( ci_service_xdata_t srv_xdata)

Enable the Partial Content 206 responses for this service.

The service will supports the Partial Content 206 responses if the icap client support it too.

Parameters
srv_xdatais a pointer to the c-icap internal service data.

◆ ci_service_set_istag()

void ci_service_set_istag ( ci_service_xdata_t srv_xdata,
const char *  istag 
)


Sets the ISTAG for the service.

Normally this function called in ci_service_module::mod_init_service() or ci_service_module::mod_post_init_service() function, while the service initialization.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
istagis a string contains the new ISTAG for the service. The istag size can not be more than a size of SERVICE_ISTAG_SIZE. If the length of istag is greater than SERVICE_ISTAG_SIZE the extra bytes are ignored.

◆ ci_service_set_max_connections()

void ci_service_set_max_connections ( ci_service_xdata_t srv_xdata,
int  max_connections 
)

Sets the maximum connection should opened by icap client to the c-icap for this service.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
max_connectionsis the maximum connections

◆ ci_service_set_options_ttl()

void ci_service_set_options_ttl ( ci_service_xdata_t srv_xdata,
int  ttl 
)

Sets the Options ttl for this service.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
ttlis the ttl value in seconds

◆ ci_service_set_preview()

void ci_service_set_preview ( ci_service_xdata_t srv_xdata,
int  preview 
)

Sets the maximum preview size supported by this service.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
previewis the size of preview data supported by this service
Examples:
services/echo/srv_echo.c.

◆ ci_service_set_transfer_complete()

void ci_service_set_transfer_complete ( ci_service_xdata_t srv_xdata,
const char *  complete 
)


Set the list of file extensions that should be send in their entirety (without preview) to this service.

The c-icap will inform the ICAP client that should send files which have the extensions contained in the complete string, in their entirety to this service.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
completeis the string which contains the list of the file extensions.

example usage:

ci_service_set_transfer_complete(srv_xdata,"exe, bat, com, ole");

◆ ci_service_set_transfer_ignore()

void ci_service_set_transfer_ignore ( ci_service_xdata_t srv_xdata,
const char *  ignore 
)


Set the list of file extensions that should NOT be send for this service.

The c-icap will inform the ICAP client that should not send files which have the extensions contained in the ignore string.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
ignoreis the string which contains the list of the file extensions.

example usage:

ci_service_set_transfer_ignore(srv_xdata,"gif, jpeg");

◆ ci_service_set_transfer_preview()

void ci_service_set_transfer_preview ( ci_service_xdata_t srv_xdata,
const char *  preview 
)


Set the list of file extensions that should previewed by the service.

The c-icap will inform the ICAP client that should send preview data for the files which have the extensions contained in the preview string. The wildcard value "*" specifies all files extensions, which is the default.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
previewis the string which contains the list of the file extensions.

example usage:

ci_service_set_transfer_preview(srv_xdata,"zip, tar");
Examples:
services/echo/srv_echo.c.

◆ ci_service_set_xopts()

void ci_service_set_xopts ( ci_service_xdata_t srv_xdata,
uint64_t  xopts 
)


Sets the service x-headers mask which defines the X-Headers supported by the service.The c-icap server will advertise these headers in options responses.

Normally this function called in ci_service_module::mod_init_service() or ci_service_module::mod_post_init_service() function, while the service is initialized.

Parameters
srv_xdatais a pointer to the c-icap internal service data.
xoptsis a compination of one or more of the following defines:
  • CI_XCLIENTIP: Refers to the X-Client-IP header. The HTTP proxy (or the ICAP client) will sends the ip address of the HTTP client using this header if supports this header.
  • CI_XSERVERIP: The X-Server-IP header. The HTTP proxy will incluse the IP of the HTTP destination host in the X-Server-IP header if supports this header.
  • CI_XSUBSCRIBERID: The X-Subscriber-ID header. This header can include a unique subscriber ID of the user who issued the HTTP request
  • CI_XAUTHENTICATEDUSER: The X-Authenticated-User header. If the user authenticated on HTTP proxy side includes the username
  • CI_XAUTHENTICATEDGROUPS: The X-Authenticated-Group header. If the user is authenticated on HTTP proxy side includes the user groups

example usage:

ci_service_set_xopts(srv_xdata,CI_XCLIENTIP|CI_XAUTHENTICATEDUSER);

For more informations about ICAP common X-Headers look at: http://www.icap-forum.org/documents/specification/draft-stecher-icap-subid-00.txt

Examples:
services/echo/srv_echo.c.