1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

http: lws_add_http_header_by_name: add colon if needed

This commit is contained in:
yogpstop 2022-01-27 21:30:08 +09:00 committed by Andy Green
parent 91f0b3bc0f
commit 637ed905af

View file

@ -78,10 +78,15 @@ lws_add_http_header_by_name(struct lws *wsi, const unsigned char *name,
(void)wsi;
#endif
if (name) {
while (*p < end && *name)
char has_colon = 0;
while (*p < end && *name) {
has_colon = has_colon || *name == ':';
*((*p)++) = *name++;
if (*p == end)
}
if (*p + (has_colon ? 1 : 2) >= end)
return 1;
if (!has_colon)
*((*p)++) = ':';
*((*p)++) = ' ';
}
if (*p + length + 3 >= end)