MCPcopy
hub / github.com/nats-io/nats.go / headerBytes

Method headerBytes

nats.go:850–873  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

848}
849
850func (m *Msg) headerBytes() ([]byte, error) {
851 var hdr []byte
852 if len(m.Header) == 0 {
853 return hdr, nil
854 }
855
856 var b bytes.Buffer
857 _, err := b.WriteString(hdrLine)
858 if err != nil {
859 return nil, ErrBadHeaderMsg
860 }
861
862 err = http.Header(m.Header).Write(&b)
863 if err != nil {
864 return nil, ErrBadHeaderMsg
865 }
866
867 _, err = b.WriteString(crlf)
868 if err != nil {
869 return nil, ErrBadHeaderMsg
870 }
871
872 return b.Bytes(), nil
873}
874
875type barrierInfo struct {
876 refs int64

Callers 7

TestHeaderMultiLineFunction · 0.95
BenchmarkHeaderDecodeFunction · 0.95
SizeMethod · 0.95
PublishMsgAsyncMethod · 0.80
PublishMsgMethod · 0.80
RequestMsgMethod · 0.80
RequestMsgWithContextMethod · 0.80

Calls 2

BytesMethod · 0.65
WriteMethod · 0.45

Tested by 2

TestHeaderMultiLineFunction · 0.76
BenchmarkHeaderDecodeFunction · 0.76