From 8e16501e074b85ef5c5225ed6ff7d5f9856232ef Mon Sep 17 00:00:00 2001 From: Garry Filakhtov Date: Mon, 25 Nov 2019 10:52:41 +1100 Subject: Replace regular expression with strings.Split() Originally, a regular expression was used to split and trim multiple comma-separated header names from "Trailer" header. This commit replaces regular expression with strings.Split() to break string into parts and then trims spaces and tabs from individual header names. --- service/http/response.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'service/http/response.go') diff --git a/service/http/response.go b/service/http/response.go index 8dda87c7..166ced82 100644 --- a/service/http/response.go +++ b/service/http/response.go @@ -4,7 +4,7 @@ import ( "encoding/json" "io" "net/http" - "regexp" + "strings" "github.com/spiral/roadrunner" ) @@ -84,9 +84,9 @@ func handleTrailers(h map[string][]string) map[string][]string { return h } - zp := regexp.MustCompile(` *, *`) for _, tr := range trailers { - for _, n := range zp.Split(tr, -1) { + for _, n := range strings.Split(tr, ",") { + n = strings.Trim(n, "\t ") if v, ok := h[n]; ok { h["Trailer:"+n] = v -- cgit v1.2.3