mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-23 00:00:06 +01:00
h2: fix multiple cookie header handling
Firefox 57 at least still sends multiple cookie: headers over h2. Correctly aggregate them with a ';' delimiter.
This commit is contained in:
parent
741ab335a7
commit
55f97b7806
2 changed files with 26 additions and 4 deletions
|
@ -247,6 +247,26 @@ static int lws_frag_start(struct lws *wsi, int hdr_token_idx)
|
||||||
|
|
||||||
ah->hdr_token_idx = hdr_token_idx;
|
ah->hdr_token_idx = hdr_token_idx;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Okay, but we could be, eg, the second or subsequent cookie: header
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (ah->frag_index[hdr_token_idx]) {
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* find the last fragment for this header... */
|
||||||
|
n = ah->frag_index[hdr_token_idx];
|
||||||
|
while (ah->frags[n].nfrag)
|
||||||
|
n = ah->frags[n].nfrag;
|
||||||
|
/* and point it to continue in our continuation fragment */
|
||||||
|
ah->frags[n].nfrag = ah->nfrag;
|
||||||
|
|
||||||
|
/* cookie continuations need a separator token of ';' */
|
||||||
|
if (hdr_token_idx == WSI_TOKEN_HTTP_COOKIE) {
|
||||||
|
ah->data[ah->pos++] = ';';
|
||||||
|
ah->frags[ah->nfrag].len++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
ah->frag_index[hdr_token_idx] = ah->nfrag;
|
ah->frag_index[hdr_token_idx] = ah->nfrag;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -299,9 +299,11 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
|
||||||
if (script_uri_path_len >= 0 &&
|
if (script_uri_path_len >= 0 &&
|
||||||
lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_COOKIE)) {
|
lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_COOKIE)) {
|
||||||
env_array[n++] = p;
|
env_array[n++] = p;
|
||||||
p += lws_snprintf(p, end - p, "HTTP_COOKIE=%s",
|
p += lws_snprintf(p, end - p, "HTTP_COOKIE=");
|
||||||
lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COOKIE));
|
m = lws_hdr_copy(wsi, p, end - p, WSI_TOKEN_HTTP_COOKIE);
|
||||||
p++;
|
if (m > 0)
|
||||||
|
p += lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_COOKIE);
|
||||||
|
*p++ = '\0';
|
||||||
}
|
}
|
||||||
if (script_uri_path_len >= 0 &&
|
if (script_uri_path_len >= 0 &&
|
||||||
lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_USER_AGENT)) {
|
lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_USER_AGENT)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue