From ca272bb55e6c7c2db20e9dfa4251257529eecd34 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 14 Oct 2014 12:55:00 +0000 Subject: [PATCH] fixed a bug of not resetting htre's flags field when clearing it --- qse/cmd/http/httpd.conf | 5 +++++ qse/include/qse/http/htre.h | 4 ++-- qse/lib/http/htre.c | 6 ++++-- qse/lib/xli/read.c | 10 +++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/qse/cmd/http/httpd.conf b/qse/cmd/http/httpd.conf index ecf6cdf6..3af3f447 100644 --- a/qse/cmd/http/httpd.conf +++ b/qse/cmd/http/httpd.conf @@ -144,6 +144,11 @@ server-default { #pseudonym = "nice-host"; + # TOOD: add-headers and remove-headers + #add-headers = "X-Forwarded-For: ${Client_Ipaddr}", + # "X-Forwarded-Proto: ${Client-Proto}"; + #remove-headers = "Connection"; + dns-enabled = yes; # yes/on, no/off dns-server = "192.168.1.1:53"; #dns-server = "[::1]:53"; diff --git a/qse/include/qse/http/htre.h b/qse/include/qse/http/htre.h index 84c91cf9..f1fcc76b 100644 --- a/qse/include/qse/http/htre.h +++ b/qse/include/qse/http/htre.h @@ -40,6 +40,7 @@ enum qse_htre_state_t QSE_HTRE_DISCARDED = (1 << 0), /** content has been discarded */ QSE_HTRE_COMPLETED = (1 << 1) /** complete content has been seen */ }; +typedef enum qse_htre_state_t qse_htre_state_t; typedef int (*qse_htre_concb_t) ( qse_htre_t* re, @@ -92,7 +93,6 @@ struct qse_htre_t } s; } u; - #define QSE_HTRE_ATTR_CHUNKED (1 << 0) #define QSE_HTRE_ATTR_LENGTH (1 << 1) #define QSE_HTRE_ATTR_KEEPALIVE (1 << 2) @@ -120,7 +120,7 @@ struct qse_htre_t qse_htre_concb_t concb; void* concb_ctx; - /* ORed of qse_htre_state_t */ + /* bitwise-ORed of qse_htre_state_t */ int state; }; diff --git a/qse/lib/http/htre.c b/qse/lib/http/htre.c index 1071488d..9628e75c 100644 --- a/qse/lib/http/htre.c +++ b/qse/lib/http/htre.c @@ -93,6 +93,7 @@ void qse_htre_clear (qse_htre_t* re) } re->state = 0; + re->flags = 0; QSE_MEMSET (&re->version, 0, QSE_SIZEOF(re->version)); QSE_MEMSET (&re->attr, 0, QSE_SIZEOF(re->attr)); @@ -104,7 +105,6 @@ void qse_htre_clear (qse_htre_t* re) #if 0 qse_mbs_clear (&re->iniline); #endif - re->state = 0; } int qse_htre_setstrfromcstr ( @@ -268,7 +268,9 @@ int qse_htre_perdecqpath (qse_htre_t* re) { /* percent decode the query path */ if (re->type != QSE_HTRE_Q || (re->flags & QSE_HTRE_QPATH_PERDEC)) return -1; - if (qse_perdechttpstr ((re)->u.q.path, (re)->u.q.path) > 0) + if (qse_perdechttpstr (re->u.q.path, re->u.q.path) > 0) + { re->flags |= QSE_HTRE_QPATH_PERDEC; + } return 0; } diff --git a/qse/lib/xli/read.c b/qse/lib/xli/read.c index 8600001c..45e7379d 100644 --- a/qse/lib/xli/read.c +++ b/qse/lib/xli/read.c @@ -806,7 +806,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) { /* check the value type */ qse_xli_seterror (xli, QSE_XLI_EILVAL, (const qse_cstr_t*)&key, &kloc); - goto oops; + goto oops; } /* add a new pair with the initial string segment */ @@ -892,7 +892,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) { /* check the value type */ qse_xli_seterror (xli, QSE_XLI_EILVAL, (const qse_cstr_t*)&key, &kloc); - goto oops; + goto oops; } xli->tok_status &= ~TOK_STATUS_ENABLE_NSTR; @@ -925,7 +925,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) if (xli->opt.trait & QSE_XLI_NONIL) { qse_xli_seterror (xli, QSE_XLI_ENOVAL, (const qse_cstr_t*)&key, &kloc); - goto oops; + goto oops; } if (scm && !(scm->flags & QSE_XLI_SCM_VALNIL) && @@ -950,7 +950,7 @@ static int read_pair (qse_xli_t* xli, const qse_char_t* keytag) else { qse_xli_seterror (xli, QSE_XLI_ELBREQ, QSE_STR_XSTR(xli->tok.name), &xli->tok.loc); - goto oops; + goto oops; } if (strtag) QSE_MMGR_FREE (xli->mmgr, strtag); @@ -980,7 +980,7 @@ static qse_xli_list_link_t* make_list_link (qse_xli_t* xli, qse_xli_list_t* parl link->next = xli->parlink; xli->parlink = link; - return link; + return link; } static void free_list_link (qse_xli_t* xli, qse_xli_list_link_t* link)