Browse Source

[multiple] replace buffer_is_equal_caseless_string

buffer_is_equal_caseless_string() -> buffer_eq_icase_slen()
master
Glenn Strauss 4 months ago
parent
commit
21f0dabef4
  1. 8
      src/buffer.c
  2. 4
      src/buffer.h
  3. 2
      src/mod_extforward.c
  4. 2
      src/request.c

8
src/buffer.c

@ -372,14 +372,6 @@ int buffer_is_equal_string(const buffer *a, const char *s, size_t b_len) {
return (a->used == b_len + 1 && 0 == memcmp(a->ptr, s, b_len));
}
/* buffer_is_equal_caseless_string(b, CONST_STR_LEN("value")) */
int buffer_is_equal_caseless_string(const buffer *a, const char *s, size_t b_len) {
force_assert(NULL != a && NULL != s);
force_assert(b_len + 1 > b_len);
/* 1 = equal; 0 = not equal */
return buffer_eq_icase_slen(a, s, b_len);
}
int buffer_is_equal_right_len(const buffer *b1, const buffer *b2, size_t len) {
/* no len -> equal */
if (len == 0) return 1;

4
src/buffer.h

@ -141,6 +141,7 @@ int buffer_eq_icase_ss(const char * const a, const size_t alen, const char * con
__attribute_pure__
int buffer_eq_icase_slen(const buffer * const b, const char * const s, const size_t slen);
#define buffer_is_equal_caseless_string buffer_eq_icase_slen
__attribute_pure__
int buffer_eq_slen(const buffer * const b, const char * const s, const size_t slen);
@ -154,9 +155,6 @@ int buffer_is_equal_right_len(const buffer *a, const buffer *b, size_t len);
__attribute_pure__
int buffer_is_equal_string(const buffer *a, const char *s, size_t b_len);
__attribute_pure__
int buffer_is_equal_caseless_string(const buffer *a, const char *s, size_t b_len);
void buffer_substr_replace (buffer * restrict b, size_t offset, size_t len, const buffer * restrict replace);
void buffer_append_string_encoded_hex_lc(buffer * restrict b, const char * restrict s, size_t len);

2
src/mod_extforward.c

@ -603,7 +603,7 @@ static int mod_extforward_set_addr(request_st * const r, plugin_data *p, const c
}
static void mod_extforward_set_proto(request_st * const r, const char * const proto, size_t protolen) {
if (0 != protolen && !buffer_is_equal_caseless_string(&r->uri.scheme, proto, protolen)) {
if (0 != protolen && !buffer_eq_icase_slen(&r->uri.scheme, proto, protolen)) {
/* update scheme if X-Forwarded-Proto is set
* Limitations:
* - Only "http" or "https" are currently accepted since the request to lighttpd currently has to

2
src/request.c

@ -491,7 +491,7 @@ static int http_request_parse_single_header(request_st * const restrict r, const
const buffer *vb =
http_header_request_get(r, HTTP_HEADER_IF_MODIFIED_SINCE,
CONST_STR_LEN("If-Modified-Since"));
if (vb && buffer_is_equal_caseless_string(vb, v, vlen)) {
if (vb && buffer_eq_icase_slen(vb, v, vlen)) {
/* ignore it if they are the same */
return 0; /* ignore header */
}

Loading…
Cancel
Save