diff --git a/lib/roles/h2/hpack.c b/lib/roles/h2/hpack.c index b59ce9f9e..843bda929 100644 --- a/lib/roles/h2/hpack.c +++ b/lib/roles/h2/hpack.c @@ -1356,8 +1356,12 @@ int lws_add_http2_header_by_name(struct lws *wsi, const unsigned char *name, *((*p)++) = 0 | lws_h2_num_start(7, len); /* non-HUF */ if (lws_h2_num(7, len, p, end)) return 1; - memcpy(*p, name, len); - *p += len; + + /* upper-case header names are verboten in h2, but OK on h1, so + * they're not illegal per se. Silently convert them for h2... */ + + while(len--) + *((*p)++) = tolower((int)*name++); *((*p)++) = 0 | lws_h2_num_start(7, length); /* non-HUF */ if (lws_h2_num(7, length, p, end)) @@ -1366,8 +1370,6 @@ int lws_add_http2_header_by_name(struct lws *wsi, const unsigned char *name, memcpy(*p, value, length); *p += length; - //lwsl_hexdump(op, *p -op); - return 0; } diff --git a/lib/roles/http/header.c b/lib/roles/http/header.c index 3312543e7..dbcf27cbd 100644 --- a/lib/roles/http/header.c +++ b/lib/roles/http/header.c @@ -212,34 +212,40 @@ lws_add_http_header_status(struct lws *wsi, unsigned int _code, #endif #ifdef LWS_WITH_HTTP2 - if (lwsi_role_h2(wsi) || lwsi_role_h2_ENCAPSULATION(wsi)) - return lws_add_http2_header_status(wsi, code, p, end); + if (lwsi_role_h2(wsi) || lwsi_role_h2_ENCAPSULATION(wsi)) { + n = lws_add_http2_header_status(wsi, code, p, end); + if (n) + return n; + } else #endif - if (code >= 400 && code < (400 + LWS_ARRAY_SIZE(err400))) - description = err400[code - 400]; - if (code >= 500 && code < (500 + LWS_ARRAY_SIZE(err500))) - description = err500[code - 500]; + { + if (code >= 400 && code < (400 + LWS_ARRAY_SIZE(err400))) + description = err400[code - 400]; + if (code >= 500 && code < (500 + LWS_ARRAY_SIZE(err500))) + description = err500[code - 500]; - if (code == 100) - description = "Continue"; - if (code == 200) - description = "OK"; - if (code == 304) - description = "Not Modified"; - else - if (code >= 300 && code < 400) - description = "Redirect"; + if (code == 100) + description = "Continue"; + if (code == 200) + description = "OK"; + if (code == 304) + description = "Not Modified"; + else + if (code >= 300 && code < 400) + description = "Redirect"; - if (wsi->http.request_version < LWS_ARRAY_SIZE(hver)) - p1 = hver[wsi->http.request_version]; - else - p1 = hver[0]; + if (wsi->http.request_version < LWS_ARRAY_SIZE(hver)) + p1 = hver[wsi->http.request_version]; + else + p1 = hver[0]; - n = sprintf((char *)code_and_desc, "%s %u %s", p1, code, description); - - if (lws_add_http_header_by_name(wsi, NULL, code_and_desc, n, p, end)) - return 1; + n = sprintf((char *)code_and_desc, "%s %u %s", p1, code, + description); + if (lws_add_http_header_by_name(wsi, NULL, code_and_desc, n, p, + end)) + return 1; + } headers = wsi->vhost->headers; while (headers) { if (lws_add_http_header_by_name(wsi, diff --git a/lib/roles/http/server/lejp-conf.c b/lib/roles/http/server/lejp-conf.c index 4b4e23a84..817a6450b 100644 --- a/lib/roles/http/server/lejp-conf.c +++ b/lib/roles/http/server/lejp-conf.c @@ -423,7 +423,7 @@ lejp_vhosts_cb(struct lejp_ctx *ctx, char reason) headers->next = a->info->headers; a->info->headers = headers; headers->name = a->p; - // lwsl_notice(" adding header %s=%s\n", a->p, ctx->buf); + lwsl_notice(" adding header %s=%s\n", a->p, ctx->buf); a->p += n - 1; *(a->p++) = ':'; if (a->p < a->end)