mirror of https://github.com/ericonr/purr-c.git
Respect that HTTP headers are case insensitive.
So we look for them using strcasestr instead fo strstr. If this ever becomes a bottleneck, it can probably be optimized by only trying to match the words right after "\r\n".
This commit is contained in:
parent
552388db2d
commit
910b69f6b2
5
files.c
5
files.c
|
@ -1,3 +1,4 @@
|
|||
#define _GNU_SOURCE /* strcasestr */
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
@ -99,8 +100,8 @@ size_t ssl_to_mmap(struct transmission_information ti)
|
|||
|
||||
if (ti.type == HTTP_CONN) {
|
||||
// http headers need to be parsed for content length
|
||||
const char *needle = "Content-Length: ";
|
||||
char *length = strstr(st.header, needle);
|
||||
const char *needle = "content-length: ";
|
||||
char *length = strcasestr(st.header, needle);
|
||||
if (length == NULL) {
|
||||
fputs("header didn't contain content-length field\n", stderr);
|
||||
rv = 0;
|
||||
|
|
Loading…
Reference in New Issue