changed how to handle http header fields.

fixed a few http proxying bugs.
This commit is contained in:
2012-04-11 15:18:51 +00:00
parent 654003e06d
commit 130bbe9e21
10 changed files with 717 additions and 336 deletions

View File

@ -39,6 +39,8 @@
#define QSE_MBS_LEN(s) ((s)->val.len)
/** string pointer */
#define QSE_MBS_PTR(s) ((s)->val.ptr)
/** pointer to a particular position */
#define QSE_MBS_CPTR(s,idx) (&(s)->val.ptr[idx])
/** string capacity */
#define QSE_MBS_CAPA(s) ((s)->capa)
/** character at the given position */
@ -54,6 +56,8 @@
#define QSE_WCS_LEN(s) ((s)->val.len)
/** string pointer */
#define QSE_WCS_PTR(s) ((s)->val.ptr)
/** pointer to a particular position */
#define QSE_WCS_CPTR(s,idx) (&(s)->val.ptr[idx])
/** string capacity */
#define QSE_WCS_CAPA(s) ((s)->capa)
/** character at the given position */
@ -79,6 +83,7 @@ typedef qse_size_t (*qse_wcs_sizer_t) (
# define QSE_STR_CSTR(s) ((qse_cstr_t*)QSE_MBS_XSTR(s))
# define QSE_STR_LEN(s) QSE_MBS_LEN(s)
# define QSE_STR_PTR(s) QSE_MBS_PTR(s)
# define QSE_STR_CPTR(s,idx) QSE_MBS_CPTR(s,idx)
# define QSE_STR_CAPA(s) QSE_MBS_CAPA(s)
# define QSE_STR_CHAR(s,idx) QSE_MBS_CHAR(s,idx)
# define QSE_STR_LASTCHAR(s) QSE_MBS_LASTCHAR(s)
@ -89,6 +94,7 @@ typedef qse_size_t (*qse_wcs_sizer_t) (
# define QSE_STR_CSTR(s) ((qse_cstr_t*)QSE_WCS_XSTR(s))
# define QSE_STR_LEN(s) QSE_WCS_LEN(s)
# define QSE_STR_PTR(s) QSE_WCS_PTR(s)
# define QSE_STR_CPTR(s,idx) QSE_WCS_CPTR(s,idx)
# define QSE_STR_CAPA(s) QSE_WCS_CAPA(s)
# define QSE_STR_CHAR(s,idx) QSE_WCS_CHAR(s,idx)
# define QSE_STR_LASTCHAR(s) QSE_WCS_LASTCHAR(s)

View File

@ -94,9 +94,6 @@ struct qse_htrd_t
qse_htob_t raw; /* buffer to hold raw octets */
qse_htob_t tra; /* buffer for handling trailers */
} b;
/* points to the head of the combined header list */
void* chl;
} fed;
qse_htre_t re;

View File

@ -25,8 +25,15 @@
#include <qse/cmn/htb.h>
#include <qse/cmn/str.h>
/*
* You should not manipulate an object of the #qse_htre_t
* type directly since it's complex. Use #qse_htrd_t to
* create an object of the qse_htre_t type.
*/
/* header and contents of request/response */
typedef struct qse_htre_t qse_htre_t;
typedef struct qse_htre_hdrval_t qse_htre_hdrval_t;
enum qse_htre_state_t
{
@ -41,6 +48,13 @@ typedef int (*qse_htre_concb_t) (
void* ctx
);
struct qse_htre_hdrval_t
{
const qse_mchar_t* ptr;
qse_size_t len;
qse_htre_hdrval_t* next;
};
struct qse_htre_t
{
qse_mmgr_t* mmgr;
@ -84,10 +98,10 @@ struct qse_htre_t
#define QSE_HTRE_ATTR_CHUNKED (1 << 0)
#define QSE_HTRE_ATTR_LENGTH (1 << 1)
#define QSE_HTRE_ATTR_KEEPALIVE (1 << 2)
#define QSE_HTRE_ATTR_EXPECT100 (1 << 3)
int flags;
qse_size_t content_length;
const qse_mchar_t* expect;
const qse_mchar_t* status;
const qse_mchar_t* status; /* for cgi */
} attr;
/* header table */
@ -127,10 +141,10 @@ struct qse_htre_t
#define qse_htre_getcontentlen(re) QSE_MBS_LEN(&(re)->content)
typedef int (*qse_htre_header_walker_t) (
qse_htre_t* re,
const qse_mchar_t* key,
const qse_mchar_t* val,
void* ctx
qse_htre_t* re,
const qse_mchar_t* key,
const qse_htre_hdrval_t* val,
void* ctx
);
#ifdef __cplusplus
@ -162,12 +176,12 @@ int qse_htre_setstrfromxstr (
const qse_mxstr_t* xstr
);
const qse_mchar_t* qse_htre_getheaderval (
const qse_htre_hdrval_t* qse_htre_getheaderval (
const qse_htre_t* re,
const qse_mchar_t* key
);
const qse_mchar_t* qse_htre_gettrailerval (
const qse_htre_hdrval_t* qse_htre_gettrailerval (
const qse_htre_t* re,
const qse_mchar_t* key
);

View File

@ -218,21 +218,21 @@ struct qse_httpd_cbs_t
typedef struct qse_httpd_task_t qse_httpd_task_t;
typedef int (*qse_httpd_task_init_t) (
qse_httpd_t* httpd,
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* task
qse_httpd_task_t* task
);
typedef void (*qse_httpd_task_fini_t) (
qse_httpd_t* httpd,
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* task
qse_httpd_task_t* task
);
typedef int (*qse_httpd_task_main_t) (
qse_httpd_t* httpd,
qse_httpd_t* httpd,
qse_httpd_client_t* client,
qse_httpd_task_t* task
qse_httpd_task_t* task
);