diff --git a/proxy/http_response_test.go b/proxy/http_response_test.go index 13a1f3941..29b3909f4 100644 --- a/proxy/http_response_test.go +++ b/proxy/http_response_test.go @@ -19,7 +19,7 @@ func TestNopHTTPResponseParser(t *testing.T) { w.Header().Set("header1", "value1") w.Write([]byte("some nice, interesting and long content")) } - req, _ := http.NewRequest("GET", "/url", nil) + req, _ := http.NewRequest("GET", "/url", http.NoBody) handler(w, req) result, err := NoOpHTTPResponseParser(context.Background(), w.Result()) if err != nil { @@ -60,7 +60,7 @@ func TestDefaultHTTPResponseParser_gzipped(t *testing.T) { gzipWriter.Write([]byte(`{"msg":"some nice, interesting and long content"}`)) gzipWriter.Flush() } - req, _ := http.NewRequest("GET", "/url", nil) + req, _ := http.NewRequest("GET", "/url", http.NoBody) req.Header.Add("Accept-Encoding", "gzip") handler(w, req) @@ -90,7 +90,7 @@ func TestDefaultHTTPResponseParser_plain(t *testing.T) { w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Write([]byte(`{"msg":"some nice, interesting and long content"}`)) } - req, _ := http.NewRequest("GET", "/url", nil) + req, _ := http.NewRequest("GET", "/url", http.NoBody) handler(w, req) result, err := DefaultHTTPResponseParserFactory(HTTPResponseParserConfig{ diff --git a/router/chi/endpoint_benchmark_test.go b/router/chi/endpoint_benchmark_test.go index 58ea62a57..02f677357 100644 --- a/router/chi/endpoint_benchmark_test.go +++ b/router/chi/endpoint_benchmark_test.go @@ -30,7 +30,7 @@ func BenchmarkEndpointHandler_ko(b *testing.B) { router := chi.NewRouter() router.Handle("/_chi_endpoint/", NewEndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_chi_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_chi_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -59,7 +59,7 @@ func BenchmarkEndpointHandler_ok(b *testing.B) { router := chi.NewRouter() router.Handle("/_chi_endpoint/", NewEndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_chi_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_chi_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -82,7 +82,7 @@ func BenchmarkEndpointHandler_ko_Parallel(b *testing.B) { router := chi.NewRouter() router.Handle("/_chi_endpoint/", NewEndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_chi_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_chi_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -113,7 +113,7 @@ func BenchmarkEndpointHandler_ok_Parallel(b *testing.B) { router := chi.NewRouter() router.Handle("/_chi_endpoint/", NewEndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_chi_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_chi_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() diff --git a/router/chi/router_test.go b/router/chi/router_test.go index fe7f51615..64b3520be 100644 --- a/router/chi/router_test.go +++ b/router/chi/router_test.go @@ -100,7 +100,7 @@ func TestDefaultFactory_ok(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, endpoint := range serviceCfg.Endpoints { - req, _ := http.NewRequest(strings.ToTitle(endpoint.Method), fmt.Sprintf("http://127.0.0.1:8062%s", endpoint.Endpoint), nil) + req, _ := http.NewRequest(strings.ToTitle(endpoint.Method), fmt.Sprintf("http://127.0.0.1:8062%s", endpoint.Endpoint), http.NoBody) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -195,7 +195,7 @@ func TestDefaultFactory_ko(t *testing.T) { {"GET", "empty"}, {"PUT", "also-ignored"}, } { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8063/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8063/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } @@ -237,7 +237,7 @@ func TestDefaultFactory_proxyFactoryCrash(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, subject := range [][]string{{"GET", "ignored"}, {"PUT", "also-ignored"}} { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8064/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8064/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } diff --git a/router/gin/endpoint_benchmark_test.go b/router/gin/endpoint_benchmark_test.go index 3cb760a29..925e40cfd 100644 --- a/router/gin/endpoint_benchmark_test.go +++ b/router/gin/endpoint_benchmark_test.go @@ -31,7 +31,7 @@ func BenchmarkEndpointHandler_ko(b *testing.B) { router := gin.New() router.GET("/_gin_endpoint/:param", EndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -61,7 +61,7 @@ func BenchmarkEndpointHandler_ok(b *testing.B) { router := gin.New() router.GET("/_gin_endpoint/:param", EndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -85,7 +85,7 @@ func BenchmarkEndpointHandler_ko_Parallel(b *testing.B) { router := gin.New() router.GET("/_gin_endpoint/:param", EndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -117,7 +117,7 @@ func BenchmarkEndpointHandler_ok_Parallel(b *testing.B) { router := gin.New() router.GET("/_gin_endpoint/:param", EndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() diff --git a/router/gin/router_test.go b/router/gin/router_test.go index 4d779858f..48683e054 100644 --- a/router/gin/router_test.go +++ b/router/gin/router_test.go @@ -97,7 +97,7 @@ func TestDefaultFactory_ok(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, endpoint := range serviceCfg.Endpoints { - req, _ := http.NewRequest(strings.ToTitle(endpoint.Method), fmt.Sprintf("http://127.0.0.1:8072%s", endpoint.Endpoint), nil) + req, _ := http.NewRequest(strings.ToTitle(endpoint.Method), fmt.Sprintf("http://127.0.0.1:8072%s", endpoint.Endpoint), http.NoBody) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -132,7 +132,7 @@ func TestDefaultFactory_ok(t *testing.T) { } } - req, _ := http.NewRequest("OPTIONS", "http://127.0.0.1:8072/some", nil) + req, _ := http.NewRequest("OPTIONS", "http://127.0.0.1:8072/some", http.NoBody) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -197,7 +197,7 @@ func TestDefaultFactory_ko(t *testing.T) { {"GET", "empty"}, {"PUT", "also-ignored"}, } { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8073/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8073/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } @@ -239,7 +239,7 @@ func TestDefaultFactory_proxyFactoryCrash(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, subject := range [][]string{{"GET", "ignored"}, {"PUT", "also-ignored"}} { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8074/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8074/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } diff --git a/router/gorilla/router_test.go b/router/gorilla/router_test.go index b63fc21fb..af3ed65d2 100644 --- a/router/gorilla/router_test.go +++ b/router/gorilla/router_test.go @@ -88,7 +88,7 @@ func TestDefaultFactory_ok(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, endpoint := range serviceCfg.Endpoints { - req, _ := http.NewRequest(endpoint.Method, fmt.Sprintf("http://127.0.0.1:8082%s", endpoint.Endpoint), nil) + req, _ := http.NewRequest(endpoint.Method, fmt.Sprintf("http://127.0.0.1:8082%s", endpoint.Endpoint), http.NoBody) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -176,7 +176,7 @@ func TestDefaultFactory_ko(t *testing.T) { {"GET", "empty"}, {"PUT", "also-ignored"}, } { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8083/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8083/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } @@ -218,7 +218,7 @@ func TestDefaultFactory_proxyFactoryCrash(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, subject := range [][]string{{"GET", "ignored"}, {"PUT", "also-ignored"}} { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8084/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8084/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } diff --git a/router/httptreemux/router_test.go b/router/httptreemux/router_test.go index 647589f23..048166036 100644 --- a/router/httptreemux/router_test.go +++ b/router/httptreemux/router_test.go @@ -88,7 +88,7 @@ func TestDefaultFactory_ok(t *testing.T) { <-time.After(5 * time.Millisecond) for _, endpoint := range serviceCfg.Endpoints { - req, _ := http.NewRequest(endpoint.Method, fmt.Sprintf("http://127.0.0.1:8082%s", endpoint.Endpoint), nil) + req, _ := http.NewRequest(endpoint.Method, fmt.Sprintf("http://127.0.0.1:8082%s", endpoint.Endpoint), http.NoBody) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -176,7 +176,7 @@ func TestDefaultFactory_ko(t *testing.T) { {"GET", "empty"}, {"PUT", "also-ignored"}, } { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8083/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8083/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } @@ -218,7 +218,7 @@ func TestDefaultFactory_proxyFactoryCrash(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, subject := range [][]string{{"GET", "ignored"}, {"PUT", "also-ignored"}} { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8084/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8084/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } diff --git a/router/mux/endpoint_benchmark_test.go b/router/mux/endpoint_benchmark_test.go index 4f9793d3c..d08f4d524 100644 --- a/router/mux/endpoint_benchmark_test.go +++ b/router/mux/endpoint_benchmark_test.go @@ -29,7 +29,7 @@ func BenchmarkEndpointHandler_ko(b *testing.B) { router := http.NewServeMux() router.Handle("/_gin_endpoint/", EndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -58,7 +58,7 @@ func BenchmarkEndpointHandler_ok(b *testing.B) { router := http.NewServeMux() router.Handle("/_gin_endpoint/", EndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -81,7 +81,7 @@ func BenchmarkEndpointHandler_ko_Parallel(b *testing.B) { router := http.NewServeMux() router.Handle("/_gin_endpoint/", EndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() @@ -112,7 +112,7 @@ func BenchmarkEndpointHandler_ok_Parallel(b *testing.B) { router := http.NewServeMux() router.Handle("/_gin_endpoint/", EndpointHandler(endpoint, p)) - req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", nil) + req, _ := http.NewRequest("GET", "http://127.0.0.1:8080/_gin_endpoint/a?b=1", http.NoBody) req.Header.Set("Content-Type", "application/json") b.ReportAllocs() diff --git a/router/mux/router_test.go b/router/mux/router_test.go index 9c33983fd..a0bf2e346 100644 --- a/router/mux/router_test.go +++ b/router/mux/router_test.go @@ -99,7 +99,7 @@ func TestDefaultFactory_ok(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, endpoint := range serviceCfg.Endpoints { - req, _ := http.NewRequest(strings.ToTitle(endpoint.Method), fmt.Sprintf("http://127.0.0.1:8062%s", endpoint.Endpoint), nil) + req, _ := http.NewRequest(strings.ToTitle(endpoint.Method), fmt.Sprintf("http://127.0.0.1:8062%s", endpoint.Endpoint), http.NoBody) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -194,7 +194,7 @@ func TestDefaultFactory_ko(t *testing.T) { {"GET", "empty"}, {"PUT", "also-ignored"}, } { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8063/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8063/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } @@ -236,7 +236,7 @@ func TestDefaultFactory_proxyFactoryCrash(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, subject := range [][]string{{"GET", "ignored"}, {"PUT", "also-ignored"}} { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8064/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8064/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } diff --git a/router/negroni/router_test.go b/router/negroni/router_test.go index a1565b38b..dc8183c5b 100644 --- a/router/negroni/router_test.go +++ b/router/negroni/router_test.go @@ -90,7 +90,7 @@ func TestDefaultFactory_ok(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, endpoint := range serviceCfg.Endpoints { - req, _ := http.NewRequest(endpoint.Method, fmt.Sprintf("http://127.0.0.1:8052%s", endpoint.Endpoint), nil) + req, _ := http.NewRequest(endpoint.Method, fmt.Sprintf("http://127.0.0.1:8052%s", endpoint.Endpoint), http.NoBody) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -162,7 +162,7 @@ func TestDefaultFactory_middlewares(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, endpoint := range serviceCfg.Endpoints { - req, _ := http.NewRequest(endpoint.Method, fmt.Sprintf("http://127.0.0.1:8090%s", endpoint.Endpoint), nil) + req, _ := http.NewRequest(endpoint.Method, fmt.Sprintf("http://127.0.0.1:8090%s", endpoint.Endpoint), http.NoBody) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { @@ -254,7 +254,7 @@ func TestDefaultFactory_ko(t *testing.T) { {"GET", "empty"}, {"PUT", "also-ignored"}, } { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8053/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8053/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } @@ -296,7 +296,7 @@ func TestDefaultFactory_proxyFactoryCrash(t *testing.T) { time.Sleep(5 * time.Millisecond) for _, subject := range [][]string{{"GET", "ignored"}, {"PUT", "also-ignored"}} { - req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8054/%s", subject[1]), nil) + req, _ := http.NewRequest(subject[0], fmt.Sprintf("http://127.0.0.1:8054/%s", subject[1]), http.NoBody) req.Header.Set("Content-Type", "application/json") checkResponseIs404(t, req) } diff --git a/transport/http/client/plugin/plugin_test.go b/transport/http/client/plugin/plugin_test.go index 2a192690f..61ee31841 100644 --- a/transport/http/client/plugin/plugin_test.go +++ b/transport/http/client/plugin/plugin_test.go @@ -1,3 +1,4 @@ +//go:build integration || !race // +build integration !race // SPDX-License-Identifier: Apache-2.0 @@ -43,7 +44,7 @@ func TestLoadWithLogger(t *testing.T) { }, }) - req, _ := http.NewRequest("GET", "http://some.example.tld/path", nil) + req, _ := http.NewRequest("GET", "http://some.example.tld/path", http.NoBody) resp, err := h(context.Background(), req) if err != nil { t.Errorf("unexpected error: %s", err.Error()) diff --git a/transport/http/server/plugin/plugin_test.go b/transport/http/server/plugin/plugin_test.go index 57c1048c0..0a55f16fd 100644 --- a/transport/http/server/plugin/plugin_test.go +++ b/transport/http/server/plugin/plugin_test.go @@ -1,3 +1,4 @@ +//go:build integration || !race // +build integration !race // SPDX-License-Identifier: Apache-2.0 @@ -53,7 +54,7 @@ func TestLoadWithLogger(t *testing.T) { return } - req, _ := http.NewRequest("GET", "http://some.example.tld/path", nil) + req, _ := http.NewRequest("GET", "http://some.example.tld/path", http.NoBody) w := httptest.NewRecorder() handler.ServeHTTP(w, req)