2014-11-19 00:06:40 +08:00
|
|
|
|
#ifndef __HTTP_PLUGIN_INCLUDE_H__
|
|
|
|
|
#define __HTTP_PLUGIN_INCLUDE_H__
|
|
|
|
|
|
|
|
|
|
#include "lib_acl.h"
|
|
|
|
|
#include "lib_protocol.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HTTP <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ע<EFBFBD>ắ<EFBFBD><EFBFBD>, <EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸտ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param dll_env {ACL_DLL_ENV*} DLL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, dll_env->logfp <EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ÿ<EFBFBD>
|
|
|
|
|
* @param dmptr {ACL_DEBUG_MEM*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Եľ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param cfg_dir {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void http_plugin_init(ACL_DLL_ENV *dll_env, const char *cfg_dir);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ắ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param client {ACL_VSTREAM*} <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param hdr_req {HTTP_HDR_REQ*} HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
* @param ctx_ptr {void**} <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>û<EFBFBD><EFBFBD>Ķ<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} < 0: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD>HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>-5xx/-4xx;
|
|
|
|
|
* 0: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; > 0: <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>̴߳<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int http_request_filter(ACL_VSTREAM *client, HTTP_HDR_REQ *hdr_req, void **ctx_ptr);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӹܴ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ắ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD><EFBFBD> http_request_filter() > 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD>ӹܸ<EFBFBD>HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HTTP<EFBFBD><EFBFBD>Ӧ
|
|
|
|
|
* @param client {ACL_VSTREAM*} HTTP<EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param hdr_req {HTTP_HDR_REQ*} <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD>HTTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
* @param ctx {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> http_request_filter <EFBFBD>е<EFBFBD> ctx_ptr
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void http_request_forward(ACL_VSTREAM *client, HTTP_HDR_REQ *hdr_req, void *ctx);
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#define DEBUG_BASE 500
|
|
|
|
|
#define DBG_REQ (DEBUG_BASE + 1)
|
|
|
|
|
#define DBG_RES (DEBUG_BASE + 2)
|
|
|
|
|
|
|
|
|
|
#define STR acl_vstring_str
|
|
|
|
|
#define LEN ACL_VSTRING_LEN
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
char *alias;
|
|
|
|
|
char *cgi;
|
|
|
|
|
HTTP_HDR_REQ *hdr_req;
|
|
|
|
|
HTTP_REQ *req;
|
|
|
|
|
HTTP_HDR_RES *hdr_res;
|
|
|
|
|
ACL_VSTREAM *client;
|
|
|
|
|
} CGI;
|
|
|
|
|
|
|
|
|
|
/* ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD> */
|
|
|
|
|
|
|
|
|
|
extern char *var_cfg_log_name;
|
|
|
|
|
extern char *var_cfg_cgi_bin;
|
|
|
|
|
extern int var_cfg_data_clone;
|
|
|
|
|
|
|
|
|
|
/* in http_conf.c */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
* @param cfg_dir {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>Ŀ¼λ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void http_conf_load(const char *cfg_dir);
|
|
|
|
|
|
|
|
|
|
/* in http_plugin.c */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳߳<EFBFBD>
|
|
|
|
|
* @param threads_limit {int} <EFBFBD>̳߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD≯߳<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param threads_idle {int} <EFBFBD>̳߳<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD>̵߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>(<EFBFBD><EFBFBD>)
|
|
|
|
|
*/
|
|
|
|
|
void http_plugin_pool_create(int threads_limit, int threads_idle);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>̳߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳߳<EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>߳̽ӹ<EFBFBD>
|
|
|
|
|
* @param start_routine {void (*)(void*)} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param arg {void*} <EFBFBD>̳߳<EFBFBD><EFBFBD>е<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>̻߳ص<EFBFBD> start_routine ʱ<EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void http_plugin_pool_append(void (*start_routine)(void *), void *arg);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ʱ<EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param level {int} <EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>𣬿<EFBFBD><EFBFBD>õļ<EFBFBD><EFBFBD><EFBFBD>Ϊ: 1, 2, 3
|
|
|
|
|
*/
|
|
|
|
|
void http_plugin_debug_memory(int level);
|
|
|
|
|
|
|
|
|
|
/* in http_cgi.c */
|
|
|
|
|
|
|
|
|
|
void http_cgi_init(void);
|
|
|
|
|
void http_cgi_end(void);
|
|
|
|
|
void http_cgi_add2(const char *alias, const char *cgi);
|
|
|
|
|
void http_cgi_add1(const ACL_ARGV *args);
|
|
|
|
|
CGI *http_cgi_path(const char *alias);
|
|
|
|
|
void http_cgi_thread(void *ctx);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|