From 7f163bcd8ff2b898b5238bed66f81639fb7c0303 Mon Sep 17 00:00:00 2001 From: wonder-mice Date: Fri, 24 Apr 2015 11:58:04 -0700 Subject: [PATCH] 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. --- lib/header.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/header.c b/lib/header.c index 8d83f5cbc..dcf73f5d3 100644 --- a/lib/header.c +++ b/lib/header.c @@ -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;