Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4355,7 +4355,7 @@ func sliceHeader(key string, hdr []byte) []byte {
if len(hdr) == 0 {
return nil
}
index := bytes.Index(hdr, stringToBytes(key))
index := bytes.Index(hdr, stringToBytes(key+":"))
hdrLen := len(hdr)
// Check that we have enough characters, this will handle the -1 case of the key not
// being found and will also handle not having enough characters for trailing CRLF.
Expand Down
20 changes: 20 additions & 0 deletions server/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,26 @@ func TestSliceHeader(t *testing.T) {
require_True(t, bytes.Equal(sliced, copied))
}

func TestSliceHeaderOrdering(t *testing.T) {
hdr := []byte("NATS/1.0\r\n\r\n")

// These headers share the same prefix, the longer subject
// must not invalidate the existence of the shorter one.
hdr = genHeader(hdr, JSExpectedLastSubjSeqSubj, "foo")
hdr = genHeader(hdr, JSExpectedLastSubjSeq, "24")

sliced := sliceHeader(JSExpectedLastSubjSeq, hdr)
copied := getHeader(JSExpectedLastSubjSeq, hdr)

require_NotNil(t, sliced)
require_Equal(t, cap(sliced), 2)

require_NotNil(t, copied)
require_Equal(t, cap(copied), len(copied))

require_True(t, bytes.Equal(sliced, copied))
}

func TestInProcessAllowedConnectionType(t *testing.T) {
tmpl := `
listen: "127.0.0.1:-1"
Expand Down
Loading