Skip to content

Commit df62a2a

Browse files
committed
http: Fix WebSockets with Firefox
Firefox (going back a couple of years 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. Closes: #772 Signed-off-by: Andrew Clayton <[email protected]>
1 parent b286640 commit df62a2a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/nxt_h1proto.c

+8-9
Original file line numberDiff line numberDiff line change
@@ -759,24 +759,23 @@ 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;
765766
field->hopbyhop = 1;
766767

767-
if (field->value_length == 5
768-
&& nxt_memcasecmp(field->value, "close", 5) == 0)
769-
{
768+
end = field->value + field->value_length;
769+
770+
if (nxt_memcasestrn(field->value, end, "close", 5) != NULL) {
770771
r->proto.h1->keepalive = 0;
772+
}
771773

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

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

0 commit comments

Comments
 (0)