Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit f7e0264

Browse files
committed
http: Fix WebSockets with Firefox
Firefox (134 at least) was unable to open a WebSocket connection to Unit due to it sending a Connection header of Connection: keep-alive, Upgrade However in Unit we were expecting only a single value in the header. Fix the 'Connection' parsing in nxt_h1p_connection() to address this. We keep the check for 'close' basically the same as that really should be the only value. Then we check for both of 'keep-alive' and 'upgrade'. Closes: #1547 Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
1 parent b4201ab commit f7e0264

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/nxt_h1proto.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ nxt_h1p_header_buffer_test(nxt_task_t *task, nxt_h1proto_t *h1p, nxt_conn_t *c,
759759
static nxt_int_t
760760
nxt_h1p_connection(void *ctx, nxt_http_field_t *field, uintptr_t data)
761761
{
762+
const u_char *end;
762763
nxt_http_request_t *r;
763764

764765
r = ctx;
@@ -768,15 +769,16 @@ nxt_h1p_connection(void *ctx, nxt_http_field_t *field, uintptr_t data)
768769
&& nxt_memcasecmp(field->value, "close", 5) == 0)
769770
{
770771
r->proto.h1->keepalive = 0;
772+
return NXT_OK;
773+
}
771774

772-
} else if (field->value_length == 10
773-
&& nxt_memcasecmp(field->value, "keep-alive", 10) == 0)
774-
{
775+
end = field->value + field->value_length;
776+
777+
if (nxt_memcasestrn(field->value, end, "keep-alive", 10) != NULL) {
775778
r->proto.h1->keepalive = 1;
779+
}
776780

777-
} else if (field->value_length == 7
778-
&& nxt_memcasecmp(field->value, "upgrade", 7) == 0)
779-
{
781+
if (nxt_memcasestrn(field->value, end, "upgrade", 7) != NULL) {
780782
r->proto.h1->connection_upgrade = 1;
781783
}
782784

0 commit comments

Comments
 (0)