From 06f3d6603683395768eccd63f9cdf45f0476420d Mon Sep 17 00:00:00 2001 From: Emile Filteau Date: Fri, 1 Nov 2019 11:41:18 -0400 Subject: [PATCH] Create a new array of string containing the encoded headers instead of modifying the headers pass as param --- message.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/message.go b/message.go index 4bffb1e..f5d2557 100644 --- a/message.go +++ b/message.go @@ -99,14 +99,16 @@ const ( // SetHeader sets a value to the given header field. func (m *Message) SetHeader(field string, value ...string) { - m.encodeHeader(value) - m.header[field] = value + m.header[field] = m.encodeHeader(value) } -func (m *Message) encodeHeader(values []string) { +func (m *Message) encodeHeader(values []string) []string { + encoded := make([]string, len(values)) for i := range values { - values[i] = m.encodeString(values[i]) + encoded[i] = m.encodeString(values[i]) } + + return encoded } func (m *Message) encodeString(value string) string {