diff options
Diffstat (limited to 'helpers_test.go')
-rw-r--r-- | helpers_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/helpers_test.go b/helpers_test.go index ccbbb6e3..1de79a35 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -248,11 +248,18 @@ func getPagesDaemonArgs(t *testing.T) []string { // Does a HTTP(S) GET against the listener specified, setting a fake // Host: and constructing the URL from the listener and the URL suffix. func GetPageFromListener(t *testing.T, spec ListenSpec, host, urlsuffix string) (*http.Response, error) { + return GetPageFromListenerWithCookie(t, spec, host, urlsuffix, "") +} + +func GetPageFromListenerWithCookie(t *testing.T, spec ListenSpec, host, urlsuffix string, cookie string) (*http.Response, error) { url := spec.URL(urlsuffix) req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } + if cookie != "" { + req.Header.Set("Cookie", cookie) + } req.Host = host @@ -279,11 +286,18 @@ func DoPagesRequest(t *testing.T, req *http.Request) (*http.Response, error) { } func GetRedirectPage(t *testing.T, spec ListenSpec, host, urlsuffix string) (*http.Response, error) { + return GetRedirectPageWithCookie(t, spec, host, urlsuffix, "") +} + +func GetRedirectPageWithCookie(t *testing.T, spec ListenSpec, host, urlsuffix string, cookie string) (*http.Response, error) { url := spec.URL(urlsuffix) req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } + if cookie != "" { + req.Header.Set("Cookie", cookie) + } req.Host = host |