This commit is contained in:
mr 2024-10-25 14:58:32 +02:00
parent cc8fc2df21
commit c34e5579fc

View File

@ -5,6 +5,8 @@ import (
"encoding/json" "encoding/json"
"io" "io"
"net/http" "net/http"
"net/url"
"strings"
) )
// HTTP Method Enum defines the different methods that can be used to interact with the HTTP server // 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{} client := &http.Client{}
return client.Do(req) 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)
}