From 854cc15ddb28e6c60ba5ffe7e5ba0a23ecd568c3 Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Tue, 11 May 2021 19:36:46 -0600 Subject: [PATCH] Fixed typos and updates checkOrigin() doc Also fixed two flappers Signed-off-by: Ivan Kozlovic --- server/mqtt_test.go | 1 + server/websocket.go | 7 ++++--- test/leafnode_test.go | 10 +++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/server/mqtt_test.go b/server/mqtt_test.go index 75745aea..18cd6872 100644 --- a/server/mqtt_test.go +++ b/server/mqtt_test.go @@ -3358,6 +3358,7 @@ func TestMQTTWill(t *testing.T) { defer nc.Close() sub := natsSubSync(t, nc, "will.topic") + natsFlush(t, nc) willMsg := []byte("bye") diff --git a/server/websocket.go b/server/websocket.go index a04cb520..940ac627 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -757,8 +757,9 @@ func wsReturnHTTPError(w http.ResponseWriter, status int, reason string) error { } // If the server is configured to accept any origin, then this function returns -// `nil` without checking if the Origin is present and valid. -// Otherwise, this will check that the Origin matches the same origine or +// `nil` without checking if the Origin is present and valid. This is also +// the case if the request does not have the Origin header. +// Otherwise, this will check that the Origin matches the same origin or // any origin in the allowed list. func (w *srvWebsocket) checkOrigin(r *http.Request) error { w.mu.RLock() @@ -772,7 +773,7 @@ func (w *srvWebsocket) checkOrigin(r *http.Request) error { if origin == _EMPTY_ { origin = r.Header.Get("Sec-Websocket-Origin") } - // If theader is not present, we will accept. + // If the header is not present, we will accept. // From https://datatracker.ietf.org/doc/html/rfc6455#section-1.6 // "Naturally, when the WebSocket Protocol is used by a dedicated client // directly (i.e., not from a web page through a web browser), the origin diff --git a/test/leafnode_test.go b/test/leafnode_test.go index 0c805d02..7207d131 100644 --- a/test/leafnode_test.go +++ b/test/leafnode_test.go @@ -427,11 +427,15 @@ func TestLeafNodeMsgDelivery(t *testing.T) { } func TestLeafNodeAndRoutes(t *testing.T) { - srvA, optsA := RunServerWithConfig("./configs/srv_a_leaf.conf") - srvB, optsB := RunServerWithConfig("./configs/srv_b.conf") - checkClusterFormed(t, srvA, srvB) + optsA := LoadConfig("./configs/srv_a_leaf.conf") + optsA.DisableShortFirstPing = true + optsB := LoadConfig("./configs/srv_b.conf") + optsB.DisableShortFirstPing = true + srvA := RunServer(optsA) defer srvA.Shutdown() + srvB := RunServer(optsB) defer srvB.Shutdown() + checkClusterFormed(t, srvA, srvB) lc := createLeafConn(t, optsA.LeafNode.Host, optsA.LeafNode.Port) defer lc.Close()