summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-06-04 21:21:41 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2019-06-06 02:48:43 -0400
commite3874a20ba9dba307d99754c1e68d056f44c726c (patch)
treebe4227bc4720090701656dedeec5bea29c3814c2
parent49ed72cef4cfaeb721f10fc18e45056b0129f3e0 (diff)
downloadlighttpd1.4-e3874a20ba9dba307d99754c1e68d056f44c726c.zip
lighttpd1.4-e3874a20ba9dba307d99754c1e68d056f44c726c.tar.gz
[core] use buffer_eq_icase* funcs
specialized buffer_eq_icase* funcs replace buffer_caseless_compare()
-rw-r--r--src/connections-glue.c2
-rw-r--r--src/http_header.c2
-rw-r--r--src/mod_extforward.c22
-rw-r--r--src/request.c14
4 files changed, 20 insertions, 20 deletions
diff --git a/src/connections-glue.c b/src/connections-glue.c
index d8c4a53..adbb375 100644
--- a/src/connections-glue.c
+++ b/src/connections-glue.c
@@ -436,7 +436,7 @@ handler_t connection_handle_read_post_state(server *srv, connection *con) {
&& con->request.http_version != HTTP_VERSION_1_0
&& chunkqueue_is_empty(con->write_queue) && con->is_writable) {
buffer *vb = http_header_request_get(con, HTTP_HEADER_EXPECT, CONST_STR_LEN("Expect"));
- if (NULL != vb && 0 == buffer_caseless_compare(CONST_BUF_LEN(vb), CONST_STR_LEN("100-continue"))) {
+ if (NULL != vb && buffer_eq_icase_slen(vb, CONST_STR_LEN("100-continue"))) {
http_header_request_unset(con, HTTP_HEADER_EXPECT, CONST_STR_LEN("Expect"));
if (!connection_write_100_continue(srv, con)) {
return HANDLER_ERROR;
diff --git a/src/http_header.c b/src/http_header.c
index 22e0d70..1c372ca 100644
--- a/src/http_header.c
+++ b/src/http_header.c
@@ -49,7 +49,7 @@ enum http_header_e http_header_hkey_get(const char *s, size_t slen) {
const struct keyvlenvalue * const kv = http_headers;
for (int i = 0; kv[i].vlen && slen >= kv[i].vlen; ++i) {
if (slen == kv[i].vlen
- && 0 == buffer_caseless_compare(s, slen, kv[i].value, kv[i].vlen))
+ && buffer_eq_icase_ssn(s, kv[i].value, slen))
return (enum http_header_e)kv[i].key;
}
return HTTP_HEADER_OTHER;
diff --git a/src/mod_extforward.c b/src/mod_extforward.c
index f100dae..321ec23 100644
--- a/src/mod_extforward.c
+++ b/src/mod_extforward.c
@@ -570,10 +570,10 @@ static void mod_extforward_set_proto(server *srv, connection *con, const char *p
if (extforward_check_proxy) {
http_header_env_set(con, CONST_STR_LEN("_L_EXTFORWARD_ACTUAL_PROTO"), CONST_BUF_LEN(con->uri.scheme));
}
- if (0 == buffer_caseless_compare(proto, protolen, CONST_STR_LEN("https"))) {
+ if (buffer_eq_icase_ss(proto, protolen, CONST_STR_LEN("https"))) {
buffer_copy_string_len(con->uri.scheme, CONST_STR_LEN("https"));
config_cond_cache_reset_item(srv, con, COMP_HTTP_SCHEME);
- } else if (0 == buffer_caseless_compare(proto, protolen, CONST_STR_LEN("http"))) {
+ } else if (buffer_eq_icase_ss(proto, protolen, CONST_STR_LEN("http"))) {
buffer_copy_string_len(con->uri.scheme, CONST_STR_LEN("http"));
config_cond_cache_reset_item(srv, con, COMP_HTTP_SCHEME);
}
@@ -735,7 +735,7 @@ static handler_t mod_extforward_Forwarded (server *srv, connection *con, plugin_
do {
j -= 3; /*(k, klen, v, vlen come in sets of 4)*/
} while ((3 != offsets[j+1] /* 3 == sizeof("for")-1 */
- || 0 != buffer_caseless_compare(s+offsets[j], 3, "for", 3))
+ || !buffer_eq_icase_ssn(s+offsets[j], "for", 3))
&& 0 != j-- && -1 != offsets[j]);
if (j < 0) break;
if (-1 == offsets[j]) { --j; continue; }
@@ -816,27 +816,27 @@ static handler_t mod_extforward_Forwarded (server *srv, connection *con, plugin_
switch (offsets[j+1]) {
#if 0
case 2:
- if (0 == buffer_caseless_compare(s+offsets[j],2,"by",2))
+ if (buffer_eq_icase_ssn(s+offsets[j], "by", 2))
oby = j;
break;
#endif
#if 0
/*(already handled above to find IP prior to earliest trusted proxy)*/
case 3:
- if (0 == buffer_caseless_compare(s+offsets[j],3,"for",3))
+ if (buffer_eq_icase_ssn(s+offsets[j], "for", 3))
ofor = j;
break;
#endif
case 4:
- if (0 == buffer_caseless_compare(s+offsets[j],4,"host",4))
+ if (buffer_eq_icase_ssn(s+offsets[j], "host", 4))
ohost = j;
break;
case 5:
- if (0 == buffer_caseless_compare(s+offsets[j],5,"proto",5))
+ if (buffer_eq_icase_ssn(s+offsets[j], "proto", 5))
oproto = j;
break;
case 11:
- if (0 == buffer_caseless_compare(s+offsets[j],11,"remote_user",11))
+ if (buffer_eq_icase_ssn(s+offsets[j], "remote_user", 11))
oremote_user = j;
break;
default:
@@ -876,7 +876,7 @@ static handler_t mod_extforward_Forwarded (server *srv, connection *con, plugin_
for (j = i; j < used && -1 == ohost; ) {
if (-1 == offsets[j]) { ++j; continue; }
if (4 == offsets[j+1]
- && 0 == buffer_caseless_compare(s+offsets[j], 4, "host", 4))
+ && buffer_eq_icase_ssn(s+offsets[j], "host", 4))
ohost = j;
j += 4; /*(k, klen, v, vlen come in sets of 4)*/
}
@@ -926,7 +926,7 @@ static handler_t mod_extforward_Forwarded (server *srv, connection *con, plugin_
for (j = i; j < used; ) {
if (-1 == offsets[j]) { ++j; continue; }
if (11 == offsets[j+1]
- && 0==buffer_caseless_compare(s+offsets[j],11,"remote_user",11))
+ && buffer_eq_icase_ssn(s+offsets[j], "remote_user", 11))
oremote_user = j;
j += 4; /*(k, klen, v, vlen come in sets of 4)*/
}
@@ -968,7 +968,7 @@ static handler_t mod_extforward_Forwarded (server *srv, connection *con, plugin_
for (j = 0; j < used; ) {
if (-1 == offsets[j]) { ++j; continue; }
if (3 == offsets[j+1]
- && 0 == buffer_caseless_compare(s+offsets[j], 3, "for", 3)) {
+ && buffer_eq_icase_ssn(s+offsets[j], "for", 3)) {
if (!buffer_string_is_empty(xff))
buffer_append_string_len(xff, CONST_STR_LEN(", "));
/* quoted-string, IPv6 brackets, and :port already removed */
diff --git a/src/request.c b/src/request.c
index d25e1e7..b72bb97 100644
--- a/src/request.c
+++ b/src/request.c
@@ -495,13 +495,13 @@ static int parse_single_header(server *srv, connection *con, parse_header_state
http_request_split_value(vals, v, vlen); /* split on , */
for (size_t vi = 0; vi < vals->used; ++vi) {
data_string *dsv = (data_string *)vals->data[vi];
- if (0 == buffer_caseless_compare(CONST_BUF_LEN(dsv->value),
- CONST_STR_LEN("keep-alive"))) {
+ if (buffer_eq_icase_slen(dsv->value,
+ CONST_STR_LEN("keep-alive"))) {
state->keep_alive_set = HTTP_CONNECTION_KEEPALIVE;
break;
}
- else if (0 == buffer_caseless_compare(CONST_BUF_LEN(dsv->value),
- CONST_STR_LEN("close"))) {
+ else if (buffer_eq_icase_slen(dsv->value,
+ CONST_STR_LEN("close"))) {
state->keep_alive_set = HTTP_CONNECTION_CLOSE;
break;
}
@@ -641,13 +641,13 @@ static size_t http_request_parse_reqline(server *srv, connection *con, buffer *h
if (*uri == '/') {
/* (common case) */
buffer_copy_string_len(con->request.uri, uri, jlen);
- } else if (0 == buffer_caseless_compare(uri, 7, "http://", 7) &&
+ } else if (jlen > 7 && buffer_eq_icase_ssn(uri, "http://", 7) &&
NULL != (nuri = memchr(uri + 7, '/', jlen-7))) {
state->reqline_host = uri + 7;
state->reqline_hostlen = nuri - state->reqline_host;
buffer_copy_string_len(con->request.uri, nuri, proto - nuri - 1);
- } else if (0 == buffer_caseless_compare(uri, 8, "https://", 8) &&
+ } else if (jlen > 8 && buffer_eq_icase_ssn(uri, "https://", 8) &&
NULL != (nuri = memchr(uri + 8, '/', jlen-8))) {
state->reqline_host = uri + 8;
state->reqline_hostlen = nuri - state->reqline_host;
@@ -864,7 +864,7 @@ int http_request_parse(server *srv, connection *con, buffer *hdrs) {
return http_request_header_line_invalid(srv, 400, "HTTP/1.0 with Transfer-Encoding (bad HTTP/1.0 proxy?) -> 400");
}
- if (0 != buffer_caseless_compare(CONST_BUF_LEN(vb), CONST_STR_LEN("chunked"))) {
+ if (!buffer_eq_icase_slen(vb, CONST_STR_LEN("chunked"))) {
/* Transfer-Encoding might contain additional encodings,
* which are not currently supported by lighttpd */
return http_request_header_line_invalid(srv, 501, NULL); /* Not Implemented */