You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
6 years ago
|
diff --git a/src/http.c b/src/http.c
|
||
|
index b45c404..aa4fd25 100644
|
||
|
--- a/src/http.c
|
||
|
+++ b/src/http.c
|
||
|
@@ -605,9 +605,9 @@ struct response {
|
||
|
resp_header_*. */
|
||
|
|
||
|
static struct response *
|
||
|
-resp_new (const char *head)
|
||
|
+resp_new (char *head)
|
||
|
{
|
||
|
- const char *hdr;
|
||
|
+ char *hdr;
|
||
|
int count, size;
|
||
|
|
||
|
struct response *resp = xnew0 (struct response);
|
||
|
@@ -636,15 +636,23 @@ resp_new (const char *head)
|
||
|
break;
|
||
|
|
||
|
/* Find the end of HDR, including continuations. */
|
||
|
- do
|
||
|
+ for (;;)
|
||
|
{
|
||
|
- const char *end = strchr (hdr, '\n');
|
||
|
+ char *end = strchr (hdr, '\n');
|
||
|
+
|
||
|
if (end)
|
||
|
hdr = end + 1;
|
||
|
else
|
||
|
hdr += strlen (hdr);
|
||
|
+
|
||
|
+ if (*hdr != ' ' && *hdr != '\t')
|
||
|
+ break;
|
||
|
+
|
||
|
+ // continuation, transform \r and \n into spaces
|
||
|
+ *end = ' ';
|
||
|
+ if (end > head && end[-1] == '\r')
|
||
|
+ end[-1] = ' ';
|
||
|
}
|
||
|
- while (*hdr == ' ' || *hdr == '\t');
|
||
|
}
|
||
|
DO_REALLOC (resp->headers, size, count + 1, const char *);
|
||
|
resp->headers[count] = NULL;
|