[core] http_method_append()

personal/stbuehler/fix-fdevent
Glenn Strauss 5 years ago
parent 90c30d5e90
commit b61ed6da2a

@ -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;
}

@ -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);
}
}

@ -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

@ -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("%"));

@ -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;

@ -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)

Loading…
Cancel
Save