MINOR: muxes/htx: Ignore pseudo header during message formatting

When an HTX message is formatted to an H1 or H2 message, pseudo-headers (with
header names starting by a colon (':')) are now ignored. In fact, for now, only
H2 messages have such headers, and the H2 mux already skips them when it creates
the HTX message. But in the futur, it may be useful to keep these headers in the
HTX message to help the message analysis or to do some processing during the
HTTP formatting. It would also be a good idea to have scopes for pseudo-headers
(:h1-, :h2-, :fcgi-...) to limit their usage to a specific mux.
This commit is contained in:
Christopher Faulet 2019-08-14 16:32:25 +02:00
parent cc3124cf44
commit 86d144c74b
2 changed files with 16 additions and 0 deletions

View File

@ -1270,6 +1270,10 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
n = htx_get_blk_name(chn_htx, blk);
v = htx_get_blk_value(chn_htx, blk);
/* Skip all pseudo-headers */
if (*(n.ptr) == ':')
goto skip_hdr;
if (isteqi(n, ist("transfer-encoding")))
h1_parse_xfer_enc_header(h1m, v);
else if (isteqi(n, ist("content-length"))) {

View File

@ -4525,6 +4525,10 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, struct htx *htx)
isteq(list[hdr].n, ist("transfer-encoding")))
continue;
/* Skip all pseudo-headers */
if (*(list[hdr].n.ptr) == ':')
continue;
if (isteq(list[hdr].n, ist("")))
break; // end
@ -4793,6 +4797,10 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
isteq(list[hdr].n, ist("transfer-encoding")))
continue;
/* Skip all pseudo-headers */
if (*(list[hdr].n.ptr) == ':')
continue;
if (isteq(list[hdr].n, ist("")))
break; // end
@ -5263,6 +5271,10 @@ static size_t h2s_make_trailers(struct h2s *h2s, struct htx *htx)
isteq(list[idx].n, ist("transfer-encoding")))
continue;
/* Skip all pseudo-headers */
if (*(list[idx].n.ptr) == ':')
continue;
if (!hpack_encode_header(&outbuf, list[idx].n, list[idx].v)) {
/* output full */
if (b_space_wraps(mbuf))