From 5e892ee5ae7f879f2b8bfc2b4c863ab2f6c94cbe Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Thu, 16 Jul 2020 12:17:07 +0200 Subject: [PATCH] add a helper to determine if headers is supported functions like Publish will return an error when headers are not supported, users who wish to support old and new servers will need a way to find out if they can use headers without parsing errors each time Signed-off-by: R.I.Pienaar --- nats.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nats.go b/nats.go index 255fcda7c..6c2bfdb09 100644 --- a/nats.go +++ b/nats.go @@ -4303,6 +4303,13 @@ func (nc *Conn) MaxPayload() int64 { return nc.info.MaxPayload } +// HeadersSupported will return if the server supports headers +func (nc *Conn) HeadersSupported() bool { + nc.mu.RLock() + defer nc.mu.RUnlock() + return nc.info.Headers +} + // AuthRequired will return if the connected server requires authorization. func (nc *Conn) AuthRequired() bool { nc.mu.RLock()