add tests to verify gzip compression headers
parent
8845a07876
commit
727f7d1ed5
|
@ -480,6 +480,54 @@ func TestHandler_DeleteRetentionPolicy_NotFound(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandler_GzipEnabled(t *testing.T) {
|
||||
srvr := OpenServer(NewMessagingClient())
|
||||
s := NewHTTPServer(srvr)
|
||||
defer s.Close()
|
||||
|
||||
req, err := http.NewRequest("GET", s.URL+`/ping`, bytes.NewBuffer([]byte{}))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Accept-Encoding", "gzip")
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if ce := resp.Header.Get("Content-Encoding"); ce != "gzip" {
|
||||
t.Fatalf("unexpected Content-Encoding. expected %q, actual: %q", "gzip", ce)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandler_GzipDisabled(t *testing.T) {
|
||||
srvr := OpenServer(NewMessagingClient())
|
||||
s := NewHTTPServer(srvr)
|
||||
defer s.Close()
|
||||
|
||||
req, err := http.NewRequest("GET", s.URL+`/ping`, bytes.NewBuffer([]byte{}))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Accept-Encoding", "")
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if ce := resp.Header.Get("Content-Encoding"); ce == "gzip" {
|
||||
t.Fatalf("unexpected Content-Encoding. expected %q, actual: %q", "", ce)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandler_Ping(t *testing.T) {
|
||||
srvr := OpenServer(NewMessagingClient())
|
||||
s := NewHTTPServer(srvr)
|
||||
|
|
Loading…
Reference in New Issue