This commit is contained in:
mr 2024-10-23 11:22:34 +02:00
parent cd902c6688
commit cc8fc2df21

View File

@ -121,7 +121,8 @@ func (caller *HTTPCaller) CallPut(url string, subpath string, body map[string]in
}
// CallRaw calls the Raw method on the HTTP server
func (caller *HTTPCaller) CallRaw(method string, url string, subpath string, body map[string]interface{}, content_type string, fakeTLSTermination bool) (*http.Response, error) {
func (caller *HTTPCaller) CallRaw(method string, url string, subpath string,
body map[string]interface{}, content_type string, fakeTLSTermination bool, cookies ...*http.Cookie) (*http.Response, error) {
postBody, _ := json.Marshal(body)
responseBody := bytes.NewBuffer(postBody)
req, err := http.NewRequest(method, url+subpath, responseBody)
@ -132,6 +133,9 @@ func (caller *HTTPCaller) CallRaw(method string, url string, subpath string, bod
if fakeTLSTermination {
req.Header.Add("X-Forwarded-Proto", "https")
}
for _, c := range cookies {
req.AddCookie(c)
}
client := &http.Client{}
return client.Do(req)
}