make the curl case of http_get not explode when no Content-Disposition (#374)

* make the curl case of http_get not explode when no Content-Disposition

* style
This commit is contained in:
Théo B.
2026-08-18 11:14:28 +02:00
committed by GitHub
parent 0e2b57d4d8
commit 4d223a1754

View File

@@ -1009,12 +1009,12 @@ static size_t curl_parse_header(char *buffer, size_t size, size_t nitems, void *
}
}
if (!strncmp(buffer, "Content-Type: ", 14))
if (!strncasecmp(buffer, "Content-Type: ", 14))
{
header->mime_type = malloc(strlen(buffer) - 13);
strncpy(header->mime_type, buffer + 14, strlen(buffer) - 14);
header->mime_type[strlen(buffer) - 14] = '\0';
} else if (!strncmp(buffer, "Content-Disposition: ", 21))
} else if (!strncasecmp(buffer, "Content-Disposition: ", 21))
{
header->filename = malloc(strlen(buffer) - 20);
memcpy(header->filename, buffer + 21, strlen(buffer) - 21);
@@ -1098,6 +1098,8 @@ static int64_t curl_http_get(const char * url, char ** out_filename, char ** buf
}
DEBUG("Content-Disposition: %s\n", header.filename);
if (out_filename)
{
if (header.filename)
{
char *filename = strstr(header.filename, "filename=");
@@ -1122,6 +1124,7 @@ static int64_t curl_http_get(const char * url, char ** out_filename, char ** buf
} else {
*out_filename = NULL;
}
}
*buf = data.result_buf;
*size = data.result_written;