diff options
author | Matus Fabian <matfabia@cisco.com> | 2024-07-31 16:08:40 +0200 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2024-08-06 16:01:02 +0000 |
commit | d46e674abc5605b58584bbf9a0607ef621ca0eee (patch) | |
tree | 4f42d19311c0036726d72d5d17af97082a05bed0 /extras/hs-test/infra/hst_suite.go | |
parent | fc3464dac99c9e3e56616e6c6bc6d10886b2f567 (diff) |
http: client POST method
Type: improvement
Change-Id: Iaa70abcee02866f9a6426a6e8e4709eeba0e8114
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras/hs-test/infra/hst_suite.go')
-rw-r--r-- | extras/hs-test/infra/hst_suite.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go index 028ab0bef1f..ff5b02eb95b 100644 --- a/extras/hs-test/infra/hst_suite.go +++ b/extras/hs-test/infra/hst_suite.go @@ -7,6 +7,8 @@ import ( "fmt" "io" "log" + "net/http" + "net/http/httputil" "os" "os/exec" "path/filepath" @@ -561,7 +563,7 @@ func (s *HstSuite) StartWget(finished chan error, server_ip, port, query, netNs } /* -runBenchmark creates Gomega's experiment with the passed-in name and samples the passed-in callback repeatedly (samplesNum times), +RunBenchmark creates Gomega's experiment with the passed-in name and samples the passed-in callback repeatedly (samplesNum times), passing in suite context, experiment and your data. You can also instruct runBenchmark to run with multiple concurrent workers. @@ -578,3 +580,19 @@ func (s *HstSuite) RunBenchmark(name string, samplesNum, parallelNum int, callba }, gmeasure.SamplingConfig{N: samplesNum, NumParallel: parallelNum}) AddReportEntry(experiment.Name, experiment) } + +/* +LogHttpReq is Gomega's ghttp server handler which logs received HTTP request. + +You should put it at the first place, so request is logged always. +*/ +func (s *HstSuite) LogHttpReq(body bool) http.HandlerFunc { + return func(w http.ResponseWriter, req *http.Request) { + dump, err := httputil.DumpRequest(req, body) + if err == nil { + s.Log("\n> Received request (" + req.RemoteAddr + "):\n" + + string(dump) + + "\n------------------------------\n") + } + } +} |