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) +}