diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2018-09-23 19:15:52 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2018-09-23 19:18:47 -0400 |
commit | b61ed6da2a4324cd562c3c5ec698f70ced4806b6 (patch) | |
tree | d8e0302a53ded3593e6387fa7703d0bf8351f66e | |
parent | 90c30d5e90a0eb1aedeebec905c468abce72d46f (diff) | |
download | lighttpd-git-b61ed6da2a4324cd562c3c5ec698f70ced4806b6.tar.gz |
[core] http_method_append()
-rw-r--r-- | src/configfile-glue.c | 12 | ||||
-rw-r--r-- | src/http_kv.c | 9 | ||||
-rw-r--r-- | src/http_kv.h | 1 | ||||
-rw-r--r-- | src/mod_accesslog.c | 2 | ||||
-rw-r--r-- | src/mod_magnet.c | 3 | ||||
-rw-r--r-- | src/mod_proxy.c | 2 |
6 files changed, 17 insertions, 12 deletions
diff --git a/src/configfile-glue.c b/src/configfile-glue.c index f37b6094..af93673e 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -428,17 +428,11 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat l = http_header_request_get(con, HTTP_HEADER_UNSPECIFIED, CONST_BUF_LEN(dc->comp_tag)); if (NULL == l) l = srv->empty_string; break; - case COMP_HTTP_REQUEST_METHOD: { - const char *method = get_http_method_name(con->request.http_method); - - /* we only have the request method as const char but we need a buffer for comparing */ - - buffer_copy_string(srv->tmp_buf, method); - + case COMP_HTTP_REQUEST_METHOD: l = srv->tmp_buf; - + buffer_string_set_length(l, 0); + http_method_append(l, con->request.http_method); break; - } default: return COND_RESULT_FALSE; } diff --git a/src/http_kv.c b/src/http_kv.c index c470661b..2ddbf7da 100644 --- a/src/http_kv.c +++ b/src/http_kv.c @@ -165,3 +165,12 @@ void http_status_append(buffer * const b, const int status) { buffer_append_string_len(b, CONST_STR_LEN(" ")); } } + +void http_method_append(buffer * const b, const http_method_t method) { + const keyvalue * const kv = http_methods; + int i; + for (i = 0; kv[i].key != method && kv[i].value; ++i) ; + if (kv[i].value) { + buffer_append_string_len(b, kv[i].value, kv[i].vlen); + } +} diff --git a/src/http_kv.h b/src/http_kv.h index 888a5770..41abb6aa 100644 --- a/src/http_kv.h +++ b/src/http_kv.h @@ -64,5 +64,6 @@ const char *get_http_method_name(http_method_t i); int get_http_version_key(const char *s); http_method_t get_http_method_key(const char *s); void http_status_append(buffer *b, int status); +void http_method_append(buffer *b, http_method_t method); #endif diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c index e1796dd1..3ffc1f0e 100644 --- a/src/mod_accesslog.c +++ b/src/mod_accesslog.c @@ -1028,7 +1028,7 @@ REQUESTDONE_FUNC(log_access_write) { con->request.http_version == HTTP_VERSION_1_1 ? "HTTP/1.1" : "HTTP/1.0", 8); break; case FORMAT_REQUEST_METHOD: - buffer_append_string(b, get_http_method_name(con->request.http_method)); + http_method_append(b, con->request.http_method); break; case FORMAT_PERCENT: buffer_append_string_len(b, CONST_STR_LEN("%")); diff --git a/src/mod_magnet.c b/src/mod_magnet.c index 4f4bc192..4d46d7e0 100644 --- a/src/mod_magnet.c +++ b/src/mod_magnet.c @@ -538,7 +538,8 @@ static buffer *magnet_env_get_buffer_by_id(server *srv, connection *con, int id) case MAGNET_ENV_URI_QUERY: dest = con->uri.query; break; case MAGNET_ENV_REQUEST_METHOD: - buffer_copy_string(srv->tmp_buf, get_http_method_name(con->request.http_method)); + buffer_string_set_length(srv->tmp_buf, 0); + http_method_append(srv->tmp_buf, con->request.http_method); dest = srv->tmp_buf; break; case MAGNET_ENV_REQUEST_URI: dest = con->request.uri; break; diff --git a/src/mod_proxy.c b/src/mod_proxy.c index 58191d50..4d02b1f1 100644 --- a/src/mod_proxy.c +++ b/src/mod_proxy.c @@ -718,7 +718,7 @@ static handler_t proxy_create_env(server *srv, gw_handler_ctx *gwhctx) { /* build header */ /* request line */ - buffer_copy_string(b, get_http_method_name(con->request.http_method)); + http_method_append(b, con->request.http_method); buffer_append_string_len(b, CONST_STR_LEN(" ")); buffer_append_string_buffer(b, con->request.uri); if (remap_headers) |