From e17a848f8abd93707f1c6edf98f9cd7d3594d17d Mon Sep 17 00:00:00 2001 From: yungtravla Date: Wed, 21 Mar 2018 20:03:07 +1000 Subject: [PATCH] Update http_proxy_js_request.go --- modules/http_proxy_js_request.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/http_proxy_js_request.go b/modules/http_proxy_js_request.go index c44078e7..9e7b8ec9 100644 --- a/modules/http_proxy_js_request.go +++ b/modules/http_proxy_js_request.go @@ -100,16 +100,13 @@ func (j *JSRequest) GetHeader(name, deflt string) string { func (j *JSRequest) SetHeader(name, value string) { name = strings.ToLower(name) - found := false - for _, h := range j.Headers { - if name == strings.ToLower(h.Name) { - found = true - h.Value = value + for i, h := range j.Headers { + if name == strings.ToLower(h.Name) { + j.Headers[i].Value = value + return } } - if found == false { - j.Headers = append(j.Headers, JSHeader{name, value}) - } + j.Headers = append(j.Headers, JSHeader{name, value}) } func (j *JSRequest) ReadBody() string {