From 6eb198bf37730160a3a28599afe41e55d0d6d6ee Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sat, 2 May 2020 10:06:18 -0700 Subject: [PATCH 1/2] Anonymous contribution from another land --- baton_test.go | 2 +- configuration.go | 2 +- csv_parsing.go | 2 +- log_writer.go | 2 +- timed_worker.go | 2 +- worker.go | 6 +++++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/baton_test.go b/baton_test.go index 7b2723f..d2deae9 100644 --- a/baton_test.go +++ b/baton_test.go @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - + package main import ( diff --git a/configuration.go b/configuration.go index 5f9e0c1..9976491 100644 --- a/configuration.go +++ b/configuration.go @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - + package main import ( diff --git a/csv_parsing.go b/csv_parsing.go index 9fc3b14..f0d255a 100644 --- a/csv_parsing.go +++ b/csv_parsing.go @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - + package main import ( diff --git a/log_writer.go b/log_writer.go index 6c567bd..2fef451 100644 --- a/log_writer.go +++ b/log_writer.go @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - + package main import "fmt" diff --git a/timed_worker.go b/timed_worker.go index 290a72c..608ccac 100644 --- a/timed_worker.go +++ b/timed_worker.go @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - + package main import ( diff --git a/worker.go b/worker.go index 9da9d82..f50baaa 100644 --- a/worker.go +++ b/worker.go @@ -97,7 +97,11 @@ func buildRequest(requests []preLoadedRequest, totalPremadeRequests int) (*fasth req.Header.SetMethod(currentReq.method) req.SetBodyString(currentReq.body) for i := 0; i < len(currentReq.headers); i++ { - req.Header.Add(currentReq.headers[i][0], currentReq.headers[i][1]) + if strings.EqualFold(currentReq.headers[i][0], "Content-type") { + req.Header.SetContentType(currentReq.headers[i][1]) + } else { + req.Header.Add(currentReq.headers[i][0], currentReq.headers[i][1]) + } } return req, resp } From 623af9a62c37dc80dd0f7a4465d2894e4d0beb23 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sat, 2 May 2020 10:11:39 -0700 Subject: [PATCH 2/2] Fixing code submission --- worker.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/worker.go b/worker.go index f50baaa..45a9264 100644 --- a/worker.go +++ b/worker.go @@ -19,6 +19,7 @@ package main import ( "github.com/valyala/fasthttp" "math/rand" + "strings" "time" ) @@ -99,9 +100,9 @@ func buildRequest(requests []preLoadedRequest, totalPremadeRequests int) (*fasth for i := 0; i < len(currentReq.headers); i++ { if strings.EqualFold(currentReq.headers[i][0], "Content-type") { req.Header.SetContentType(currentReq.headers[i][1]) - } else { - req.Header.Add(currentReq.headers[i][0], currentReq.headers[i][1]) + continue } + req.Header.Add(currentReq.headers[i][0], currentReq.headers[i][1]) } return req, resp }