ISSUE-9507: TEST server with varied Accept Header

Signed-off-by: Matt Clegg <m@cle.gg>
pull/13034/head^2
Matt Clegg 6 months ago
parent fff3547f9c
commit 3c39705212
No known key found for this signature in database
GPG Key ID: 4103D2455B460CD0

@ -280,6 +280,29 @@ func TestDownload(t *testing.T) {
if got.String() != expect {
t.Errorf("Expected %q, got %q", expect, got.String())
}
// test server with varied Accept Header
const expectedAcceptHeader = "application/gzip,application/octet-stream"
acceptHeaderSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Accept") != expectedAcceptHeader {
t.Errorf("Expected '%s', got '%s'", expectedAcceptHeader, r.Header.Get("Accept"))
}
fmt.Fprint(w, expect)
}))
defer acceptHeaderSrv.Close()
u, _ = url.ParseRequestURI(acceptHeaderSrv.URL)
httpgetter, err = NewHTTPGetter(
WithAcceptHeader(expectedAcceptHeader),
)
if err != nil {
t.Fatal(err)
}
_, err = httpgetter.Get(u.String())
if err != nil {
t.Fatal(err)
}
}
func TestDownloadTLS(t *testing.T) {

Loading…
Cancel
Save