mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
Make http header parsing case insensitive (#13267)
This commit is contained in:
parent
71b30d7846
commit
85a256e2cb
@ -130,6 +130,25 @@ static INLINE bool string_is_equal_case_insensitive(const char *a,
|
||||
return (result == 0);
|
||||
}
|
||||
|
||||
static INLINE bool string_starts_with_case_insensitive(const char *str,
|
||||
const char *prefix)
|
||||
{
|
||||
int result = 0;
|
||||
const unsigned char *p1 = (const unsigned char*)str;
|
||||
const unsigned char *p2 = (const unsigned char*)prefix;
|
||||
|
||||
if (!str || !prefix)
|
||||
return false;
|
||||
if (p1 == p2)
|
||||
return true;
|
||||
|
||||
while ((result = tolower (*p1++) - tolower (*p2)) == 0)
|
||||
if (*p2++ == '\0')
|
||||
break;
|
||||
|
||||
return (result == 0 || *p2 == '\0');
|
||||
}
|
||||
|
||||
char *string_to_upper(char *s);
|
||||
|
||||
char *string_to_lower(char *s);
|
||||
|
@ -898,14 +898,13 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strncmp(state->data, "Content-Length: ",
|
||||
STRLEN_CONST("Content-Length: ")))
|
||||
if (string_starts_with_case_insensitive(state->data, "Content-Length: "))
|
||||
{
|
||||
state->bodytype = T_LEN;
|
||||
state->len = strtol(state->data +
|
||||
STRLEN_CONST("Content-Length: "), NULL, 10);
|
||||
}
|
||||
if (string_is_equal(state->data, "Transfer-Encoding: chunked"))
|
||||
if (string_is_equal_case_insensitive(state->data, "Transfer-Encoding: chunked"))
|
||||
state->bodytype = T_CHUNK;
|
||||
|
||||
/* TODO: save headers somewhere */
|
||||
|
Loading…
x
Reference in New Issue
Block a user