mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
Fixed headers support for inbound leafnode connection
The server that solicits a LeafNode connection does not send an INFO, so the accepting side had no way to know if the remote supports headers or not. The solicit side will now send the headers support capability in the CONNECT protocol so that the receiving side can mark the inbound connection with headers support based on that and its own support for headers. Resolves #1781 Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -4240,3 +4240,61 @@ func TestLeafNodeStreamAndShadowSubs(t *testing.T) {
|
||||
t.Fatalf("Did not receive message: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLeafnodeHeaders(t *testing.T) {
|
||||
srv, opts := runLeafServer()
|
||||
defer srv.Shutdown()
|
||||
leaf, _ := runSolicitLeafServer(opts)
|
||||
defer leaf.Shutdown()
|
||||
|
||||
snc, err := nats.Connect(srv.ClientURL())
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
}
|
||||
defer snc.Close()
|
||||
ssub, err := snc.SubscribeSync("test")
|
||||
if err != nil {
|
||||
t.Fatalf("subscribe failed: %s", err)
|
||||
}
|
||||
|
||||
lnc, err := nats.Connect(leaf.ClientURL())
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
}
|
||||
defer lnc.Close()
|
||||
lsub, err := lnc.SubscribeSync("test")
|
||||
if err != nil {
|
||||
t.Fatalf("subscribe failed: %s", err)
|
||||
}
|
||||
lnc.Flush()
|
||||
|
||||
checkLeafNodeConnected(t, srv)
|
||||
checkLeafNodeConnected(t, leaf)
|
||||
checkSubInterest(t, srv, "$G", "test", time.Second)
|
||||
|
||||
msg := nats.NewMsg("test")
|
||||
msg.Header.Add("Test", "Header")
|
||||
if len(msg.Header) == 0 {
|
||||
t.Fatalf("msg header is empty")
|
||||
}
|
||||
err = snc.PublishMsg(msg)
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
smsg, err := ssub.NextMsg(time.Second)
|
||||
if err != nil {
|
||||
t.Fatalf("next failed: %s", err)
|
||||
}
|
||||
if len(smsg.Header) == 0 {
|
||||
t.Fatalf("server msgs header is empty")
|
||||
}
|
||||
|
||||
lmsg, err := lsub.NextMsg(time.Second)
|
||||
if err != nil {
|
||||
t.Fatalf("next failed: %s", err)
|
||||
}
|
||||
if len(lmsg.Header) == 0 {
|
||||
t.Fatalf("leaf msg header is empty")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user