Skip to content

Commit

Permalink
Create a new array of string containing the encoded headers instead o…
Browse files Browse the repository at this point in the history
…f modifying the headers pass as param
  • Loading branch information
Emile-Filteau committed Nov 1, 2019
1 parent f59b9b8 commit 8f3f176
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ func (m *Message) SetBoundary(boundary string) {

// 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 {
Expand Down

0 comments on commit 8f3f176

Please sign in to comment.