From 244c17fa2e06f9b52b10328a31503eed660035cf Mon Sep 17 00:00:00 2001 From: Lu Qiuwen Date: Fri, 21 Sep 2018 15:00:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=87=E5=87=86HTTP?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E8=BD=AC=E6=8D=A2=E4=B8=BA=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E7=9A=84=E5=B7=A5=E5=85=B7=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/include/tfe_http.h | 5 +++++ common/src/tfe_http.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/common/include/tfe_http.h b/common/include/tfe_http.h index 0a96344..053917e 100644 --- a/common/include/tfe_http.h +++ b/common/include/tfe_http.h @@ -202,11 +202,16 @@ typedef void (http_session_data_cb)(const struct tfe_stream * stream, typedef void (http_session_end_cb)(const struct tfe_stream * stream, const struct tfe_http_session * session, unsigned int thread_id, void ** pme); +/* Tools functions for standard HTTP header field name */ struct http_field_name * http_field_name_duplicate(const struct http_field_name * orig); int http_field_name_compare(const struct http_field_name * lvalue, const struct http_field_name * rvalue); const char * http_field_to_string(const struct http_field_name * field); void http_field_destory(struct http_field_name *); +/* Tools functions for standard HTTP method */ +const char * http_std_method_to_string(enum tfe_http_std_method method); +enum tfe_http_std_method http_std_method_construct(const char * str_method); + static inline const char * tfe_http_field_read(const struct tfe_http_half * half, const struct http_field_name * name) { diff --git a/common/src/tfe_http.cpp b/common/src/tfe_http.cpp index 5916121..774dfcd 100644 --- a/common/src/tfe_http.cpp +++ b/common/src/tfe_http.cpp @@ -43,6 +43,18 @@ static const char * __str_std_header_field_map[] = [TFE_HTTP_ACCEPT_ENCODING] = "Accept-Encoding" }; +static const char * __str_std_method_map[] = +{ +#define XX(num, name, string) [TFE_HTTP_##name] = #string, + HTTP_METHOD_MAP(XX) +#undef XX +}; + +const char * http_std_method_to_string(enum tfe_http_std_method method) +{ + return __str_std_method_map[method]; +} + struct http_field_name * http_field_name_duplicate(const struct http_field_name * orig) { struct http_field_name * __duplicated = ALLOC(struct http_field_name, 1);