From c34e5579fcfcac6a4a1a07a08280c185d21ad656 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 25 Oct 2024 14:58:32 +0200 Subject: [PATCH] test --- tools/remote_caller.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/remote_caller.go b/tools/remote_caller.go index 492ddba..b7eb5de 100644 --- a/tools/remote_caller.go +++ b/tools/remote_caller.go @@ -5,6 +5,8 @@ import ( "encoding/json" "io" "net/http" + "net/url" + "strings" ) // HTTP Method Enum defines the different methods that can be used to interact with the HTTP server @@ -139,3 +141,21 @@ func (caller *HTTPCaller) CallRaw(method string, url string, subpath string, client := &http.Client{} return client.Do(req) } + +// CallRaw calls the Raw method on the HTTP server +func (caller *HTTPCaller) CallForm(method string, url string, subpath string, + body url.Values, content_type string, fakeTLSTermination bool, cookies ...*http.Cookie) (*http.Response, error) { + req, err := http.NewRequest(method, url+subpath, strings.NewReader(body.Encode())) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", content_type) + if fakeTLSTermination { + req.Header.Add("X-Forwarded-Proto", "https") + } + for _, c := range cookies { + req.AddCookie(c) + } + client := &http.Client{} + return client.Do(req) +}