add support for http client uploads

fixes #27
This commit is contained in:
Lucas Clemente
2016-05-13 13:01:45 +02:00
parent c0c7650431
commit d1272650c3
6 changed files with 59 additions and 48 deletions

View File

@@ -6,15 +6,24 @@ import (
"golang.org/x/net/http2"
"golang.org/x/net/http2/hpack"
"github.com/lucas-clemente/quic-go/protocol"
"github.com/lucas-clemente/quic-go/testdata"
"github.com/lucas-clemente/quic-go/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
type mockSession struct{}
func (s *mockSession) GetOrCreateStream(id protocol.StreamID) (utils.Stream, error) {
return &mockStream{}, nil
}
var _ = Describe("Response Writer", func() {
var (
s *Server
s *Server
session *mockSession
)
BeforeEach(func() {
@@ -22,6 +31,7 @@ var _ = Describe("Response Writer", func() {
s, err = NewServer(testdata.GetTLSConfig())
Expect(err).NotTo(HaveOccurred())
Expect(s).NotTo(BeNil())
session = &mockSession{}
})
It("uses default handler", func() {
@@ -63,11 +73,10 @@ var _ = Describe("Response Writer", func() {
// Taken from https://http2.github.io/http2-spec/compression.html#request.examples.with.huffman.coding
0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff,
})
err := s.handleRequest(nil, headerStream, hpackDecoder, h2framer)
err := s.handleRequest(session, headerStream, hpackDecoder, h2framer)
Expect(err).NotTo(HaveOccurred())
Eventually(func() bool { return handlerCalled }).Should(BeTrue())
})
})
It("handles the header stream", func() {
@@ -82,7 +91,7 @@ var _ = Describe("Response Writer", func() {
// Taken from https://http2.github.io/http2-spec/compression.html#request.examples.with.huffman.coding
0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff,
})
s.handleStream(nil, headerStream)
s.handleStream(session, headerStream)
Eventually(func() bool { return handlerCalled }).Should(BeTrue())
})
})