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

Don't require ':' to be a part of header name in lws_add_http_header_by_name

Also don't append space after a colon (":"), since it's not required.

RFC 2616, 4.2 Message Headers:

Each header field consists of a name **followed by** a colon (":") and the
field value. The field value MAY be preceded by any amount of LWS,
though a single SP is preferred.
This commit is contained in:
wonder-mice 2015-04-24 11:58:04 -07:00
parent 2d8baa1128
commit 7f163bcd8f

View file

@ -42,11 +42,14 @@ int lws_add_http_header_by_name(struct libwebsocket_context *context,
return lws_add_http2_header_by_name(context, wsi, name, value, length, p, end);
#endif
if (name) {
char sep = '\0';
while (*p < end && *name)
*((*p)++) = *name++;
if (*p == end)
return 1;
*((*p)++) = ' ';
*((*p)++) = sep = *name++;
if (':' != sep) {
if (*p == end)
return 1;
*((*p)++) = ':';
}
}
if (*p + length + 3 >= end)
return 1;