integration: Add HTTP/2 chunked request body test
This commit is contained in:
parent
467565589c
commit
5436c95788
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/bradfitz/http2"
|
||||
"github.com/bradfitz/http2/hpack"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
@ -173,3 +174,30 @@ func TestHTTP2LocationRewrite(t *testing.T) {
|
|||
t.Errorf("Location: %v; want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTP2ChunkedRequestBody(t *testing.T) {
|
||||
st := newServerTester(nil, t, func(w http.ResponseWriter, r *http.Request) {
|
||||
want := "[chunked]"
|
||||
if got := fmt.Sprint(r.TransferEncoding); got != want {
|
||||
t.Errorf("Transfer-Encoding: %v; want %v", got, want)
|
||||
}
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
t.Errorf("Error reading r.body: %v", err)
|
||||
}
|
||||
want = "foo"
|
||||
if got := string(body); got != want {
|
||||
t.Errorf("body: %v; want %v", got, want)
|
||||
}
|
||||
})
|
||||
defer st.Close()
|
||||
|
||||
_, err := st.http2(requestParam{
|
||||
name: "TestHTTP2ChunkedRequestBody",
|
||||
method: "POST",
|
||||
body: []byte("foo"),
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("Error st.http2() = %v", err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue