integration: Add HTTP/2 chunked request body test

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-19 22:20:56 +09:00
parent 467565589c
commit 5436c95788
1 changed files with 28 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/bradfitz/http2" "github.com/bradfitz/http2"
"github.com/bradfitz/http2/hpack" "github.com/bradfitz/http2/hpack"
"io/ioutil"
"net/http" "net/http"
"testing" "testing"
) )
@ -173,3 +174,30 @@ func TestHTTP2LocationRewrite(t *testing.T) {
t.Errorf("Location: %v; want %v", got, want) 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)
}
}