From 5827cdcde92d66a8f242f89766898cf475277336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kenan=20Faruk=20=C3=87ak=C4=B1r?= Date: Mon, 29 May 2023 09:14:37 +0300 Subject: [PATCH 1/3] check status code for remote file on multipart --- config/json.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/json.go b/config/json.go index 849ca1fe..00a44f5f 100644 --- a/config/json.go +++ b/config/json.go @@ -443,6 +443,12 @@ func prepareMultipartPayload(parts []multipartFormData) (body string, contentTyp return "", "", err } + if !(response.StatusCode >= 200 && response.StatusCode <= 299) { + multipartError.wrappedErr = fmt.Errorf("request to remote file returned status code %d", response.StatusCode) + multipartError.msg = "Error while getting remote file" + return "", "", multipartError + } + _, err = io.Copy(formPart, response.Body) if err != nil { multipartError.wrappedErr = err From c397bbf3426e56809698c5cdccf7c36f0411b005 Mon Sep 17 00:00:00 2001 From: fatihbaltaci Date: Mon, 29 May 2023 16:45:37 +0300 Subject: [PATCH 2/3] Update error msg --- config/json.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/json.go b/config/json.go index 00a44f5f..7c197ade 100644 --- a/config/json.go +++ b/config/json.go @@ -444,8 +444,8 @@ func prepareMultipartPayload(parts []multipartFormData) (body string, contentTyp } if !(response.StatusCode >= 200 && response.StatusCode <= 299) { - multipartError.wrappedErr = fmt.Errorf("request to remote file returned status code %d", response.StatusCode) - multipartError.msg = "Error while getting remote file" + multipartError.wrappedErr = fmt.Errorf("Multipart: request to remote url (%s) failed. Status code: %d", part.Value, response.StatusCode) + multipartError.msg = "Error while getting remote multipart file" return "", "", multipartError } From 0459b02eb4b085313694de0c9d8e9ba6fac2f8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kenan=20Faruk=20=C3=87ak=C4=B1r?= Date: Mon, 29 May 2023 16:55:49 +0300 Subject: [PATCH 3/3] increase cpu time threshold on benchmark --- main_benchmark_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main_benchmark_test.go b/main_benchmark_test.go index b70979cc..38fe92b1 100644 --- a/main_benchmark_test.go +++ b/main_benchmark_test.go @@ -151,7 +151,7 @@ var table = []struct { { name: "config_multipart_inject_1krps", path: "config/config_testdata/benchmark/config_multipart_inject_1krps.json", - cpuTimeThreshold: 180, + cpuTimeThreshold: 200, maxMemThreshold: 10, avgMemThreshold: 15, testType: Multipart,