Skip to content

Commit b84762b

Browse files
committed
BUG/MINOR: h3: don't insert more than one Host header
Let's make sure we drop extraneous Host headers after having compared them. That also works when :authority was already present. This way, like for h1 and h2, we only keep one copy of it, while still making sure that Host matches :authority. This way, if a request has both :authority and Host, only one Host header will be produced (from :authority). Note that due to the different organization of the code and wording along the evolving RFCs, here we also check that all duplicates are identical, while h2 ignores them as per RFC7540, but this will be re-unified later. This should be backported to stable versions, at least 2.8, though thanks to the existing checks the impact is probably nul.
1 parent f45a632 commit b84762b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/h3.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,12 +861,20 @@ static ssize_t h3_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
861861
}
862862

863863
if (isteq(list[hdr_idx].n, ist("host"))) {
864+
struct ist prev_auth = authority;
865+
864866
if (h3_set_authority(qcs, &authority, list[hdr_idx].v)) {
865867
h3s->err = H3_ERR_MESSAGE_ERROR;
866868
qcc_report_glitch(h3c->qcc, 1);
867869
len = -1;
868870
goto out;
869871
}
872+
873+
if (isttest(prev_auth)) {
874+
/* skip duplicate Host header */
875+
++hdr_idx;
876+
continue;
877+
}
870878
}
871879
else if (isteq(list[hdr_idx].n, ist("cookie"))) {
872880
http_cookie_register(list, hdr_idx, &cookie, &last_cookie);

0 commit comments

Comments
 (0)