diff options
-rw-r--r-- | internal/customheaders/customheaders.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/customheaders/customheaders.go b/internal/customheaders/customheaders.go index 96662fe1..92f50069 100644 --- a/internal/customheaders/customheaders.go +++ b/internal/customheaders/customheaders.go @@ -7,6 +7,8 @@ import ( "net/http" "net/textproto" "strings" + + "github.com/hashicorp/go-multierror" ) var ( @@ -27,23 +29,28 @@ func AddCustomHeaders(w http.ResponseWriter, headers http.Header) { func ParseHeaderString(customHeaders []string) (http.Header, error) { headers := make(http.Header, len(customHeaders)) + var result *multierror.Error for _, h := range customHeaders { h = h + "\n\n" tp := textproto.NewReader(bufio.NewReader(strings.NewReader(h))) mimeHeader, err := tp.ReadMIMEHeader() if err != nil { - return nil, fmt.Errorf("parsing error %s: %w", h, errInvalidHeaderParameter) + result = multierror.Append(result, fmt.Errorf("parsing error %s: %w", h, errInvalidHeaderParameter)) } for key, value := range mimeHeader { if _, ok := headers[key]; ok { - return nil, fmt.Errorf("%s already specified with value '%s': %w", key, value, errDuplicateHeader) + result = multierror.Append(result, fmt.Errorf("%s already specified with value '%s': %w", key, value, errDuplicateHeader)) } headers[key] = value } } + if result.ErrorOrNil() != nil { + return nil, result + } + return headers, nil } |