diff --git a/tests/common.c b/tests/common.c index 20b7159e..b1cc264f 100644 --- a/tests/common.c +++ b/tests/common.c @@ -331,45 +331,6 @@ body_beginning(const bytevec *vec) return (char *)result + 4; } -const char * -get_first_header_value(const char *headers, const size_t headers_len, - const char *name, const size_t name_len, size_t *n) -{ - const char *current = headers; - size_t len = headers_len; - - // We use + 3 because there needs to be room for `:` and `\r\n` after the - // header name - while(len > name_len + 3) { - const void *result = memmem(current, len, "\r\n", 2); - if(result == NULL) { - return NULL; - } - const size_t skipped = (char *)result - current + 2; - len -= skipped; - current += skipped; - /* Make sure there's enough room to conceivably contain the header name, - * a colon (:), and something after that. - */ - if(len < name_len + 2) { - return NULL; - } - if(strncasecmp(name, current, name_len) == 0 && current[name_len] == ':') { - /* Found it! */ - len -= name_len + 1; - current += name_len + 1; - result = memmem(current, len, "\r\n", 2); - if(result == NULL) { - *n = len; - return current; - } - *n = (char *)result - current; - return current; - } - } - return NULL; -} - void log_cb(void *userdata, const rustls_log_params *params) { diff --git a/tests/common.h b/tests/common.h index 53e493a1..1a8cc76b 100644 --- a/tests/common.h +++ b/tests/common.h @@ -131,16 +131,6 @@ void *memmem(const void *haystack, size_t haystacklen, const void *needle, */ char *body_beginning(const bytevec *vec); -/* If any header matching the provided name (NUL-terminated) exists, return - * a pointer to the beginning of the value for the first such occurrence - * and store the length of the header in n. - * If no such header exists, return NULL and don't modify n. - * The returned pointer will be borrowed from `headers`. - */ -const char *get_first_header_value(const char *headers, size_t headers_len, - const char *name, size_t name_len, - size_t *n); - void log_cb(void *userdata, const rustls_log_params *params); demo_result read_file(const char *filename, char *buf, size_t buflen,