Documentation ¶
Index ¶
- Constants
- Variables
- func CommonHeaders(c *config.Config) []hpack.HeaderField
- func CommonRespHeaders(c *config.Config) []hpack.HeaderField
- func DummyBytes(len int) []byte
- func DummyHeaders(c *config.Config, len int) []hpack.HeaderField
- func DummyRespHeaders(c *config.Config, len int) []hpack.HeaderField
- func DummyString(len int) string
- func HeaderField(name, value string) hpack.HeaderField
- func ServerDataLength(c *config.Config) (int, error)
- func VerifyConnectionClose(conn *Conn) error
- func VerifyConnectionError(conn *Conn, codes ...http2.ErrCode) error
- func VerifyErrorCode(codes []http2.ErrCode, code http2.ErrCode) bool
- func VerifyEventType(conn *Conn, et EventType) error
- func VerifyHeadersFrame(conn *Conn, streamID uint32) error
- func VerifyPingFrameOrConnectionClose(conn *Conn, data [8]byte) error
- func VerifyPingFrameWithAck(conn *Conn, data [8]byte) error
- func VerifySettingsFrameWithAck(conn *Conn) error
- func VerifyStreamClose(conn *Conn) error
- func VerifyStreamError(conn *Conn, codes ...http2.ErrCode) error
- type ClientTestCase
- type ClientTestGroup
- func (tg *ClientTestGroup) AddTestCase(tc *ClientTestCase)
- func (tg *ClientTestGroup) AddTestGroup(stg *ClientTestGroup)
- func (tg *ClientTestGroup) ClientTestCases(testCases map[int]*ClientTestCase, c *config.Config, currentPort int) int
- func (tg *ClientTestGroup) ID() string
- func (tg *ClientTestGroup) IncRecursive(failed bool, skipped bool, inc int)
- func (tg *ClientTestGroup) IsRoot() bool
- func (tg *ClientTestGroup) Level() int
- func (tg *ClientTestGroup) Test(c *config.Config)
- func (tg *ClientTestGroup) Title() string
- type ClientTestResult
- type Conn
- func (conn *Conn) EncodeHeaders(headers []hpack.HeaderField) []byte
- func (conn *Conn) Handshake() error
- func (conn *Conn) MaxFrameSize() int
- func (conn *Conn) ReadClientPreface() (string, error)
- func (conn *Conn) ReadRequest() (*Request, error)
- func (conn *Conn) Send(payload []byte) error
- func (conn *Conn) SetMaxDynamicTableSize(v uint32)
- func (conn *Conn) WaitEvent() Event
- func (conn *Conn) WaitEventByType(evt EventType) (Event, bool)
- func (conn *Conn) WriteContinuation(streamID uint32, endHeaders bool, headerBlockFragment []byte) error
- func (conn *Conn) WriteData(streamID uint32, endStream bool, data []byte) error
- func (conn *Conn) WriteDataPadded(streamID uint32, endStream bool, data, pad []byte) error
- func (conn *Conn) WriteGoAway(maxStreamID uint32, code http2.ErrCode, debugData []byte) error
- func (conn *Conn) WriteHeaders(p http2.HeadersFrameParam) error
- func (conn *Conn) WritePing(ack bool, data [8]byte) error
- func (conn *Conn) WritePriority(streamID uint32, p http2.PriorityParam) error
- func (conn *Conn) WritePushPromise(p http2.PushPromiseParam) error
- func (conn *Conn) WriteRSTStream(streamID uint32, code http2.ErrCode) error
- func (conn *Conn) WriteRawFrame(t http2.FrameType, flags http2.Flags, streamID uint32, payload []byte) error
- func (conn *Conn) WriteSettings(settings ...http2.Setting) error
- func (conn *Conn) WriteSettingsAck() error
- func (conn *Conn) WriteSuccessResponse(streamID uint32, c *config.Config)
- func (conn *Conn) WriteWindowUpdate(streamID, incr uint32) error
- type ConnectionClosedEvent
- type ContinuationFrameEvent
- type DataFrameEvent
- type ErrorEvent
- type Event
- type EventFrame
- type EventType
- type GoAwayFrameEvent
- type HeadersFrameEvent
- type PingFrameEvent
- type PriorityFrameEvent
- type PushPromiseFrameEvent
- type RSTStreamFrameEvent
- type RawDataEvent
- type Request
- type Server
- type SettingsFrameEvent
- type TestCase
- type TestError
- type TestGroup
- type TestResult
- type TimeoutEvent
- type WindowUpdateFrameEvent
Constants ¶
const ( // DefaultWindowSize is the value of default connection window size. DefaultWindowSize = 65535 // DefaultFrameSize is the value of default frame size. DefaultFrameSize = 16384 )
const ( ExpectedConnectionClosed = "Connection closed" ExpectedStreamClosed = "Stream closed" ExpectedGoAwayFrame = "GOAWAY Frame (Error Code: %s)" ExpectedRSTStreamFrame = "RST_STREAM Frame (Error Code: %s)" )
Variables ¶
var ( DefaultLength uint32 = math.MaxUint32 DefaultFlags http2.Flags = math.MaxUint8 DefaultErrCode http2.ErrCode = math.MaxUint8 )
var ( // ErrTimeout is used when the test times out. ErrTimeout = errors.New("Timeout") // ErrSkipped is used when the test skipped. ErrSkipped = errors.New("Skipped") )
Functions ¶
func CommonHeaders ¶
func CommonHeaders(c *config.Config) []hpack.HeaderField
CommonHeaders returns a array of header field of HPACK contained common http headers used in various test case.
func CommonRespHeaders ¶
func CommonRespHeaders(c *config.Config) []hpack.HeaderField
CommonRespHeaders returns a array of header field of HPACK contained common http headers used in various test case.
func DummyBytes ¶
DummyBytes returns a array of byte with specified length.
func DummyHeaders ¶
func DummyHeaders(c *config.Config, len int) []hpack.HeaderField
DummyHeaders returns a array of header field of HPACK contained dummy string values.
func DummyRespHeaders ¶
func DummyRespHeaders(c *config.Config, len int) []hpack.HeaderField
func DummyString ¶
DummyString returns a dummy string with specified length.
func HeaderField ¶
func HeaderField(name, value string) hpack.HeaderField
HeaderField returns a header field of HPACK with specified name and value.
func ServerDataLength ¶
ServerDataLength returns the total length of the DATA frame of /.
func VerifyConnectionClose ¶
VerifyConnectionClose verifies whether the connection was closed.
func VerifyConnectionError ¶
VerifyConnectionError verifies whether a connection error of HTTP/2 has occurred.
func VerifyErrorCode ¶
VerifyErrorCode verifies whether the specified error code is the expected error code.
func VerifyEventType ¶
VerifyEventType verifies whether a frame with specified type has received.
func VerifyHeadersFrame ¶
VerifyHeadersFrame verifies whether a HEADERS frame with specified stream ID has received.
func VerifyPingFrameOrConnectionClose ¶
VerifyPingFrameOrConnectionClose verifies whether a PING frame with ACK flag has received or the connection was closed.
func VerifyPingFrameWithAck ¶
VerifyPingFrameWithAck verifies whether a PING frame with ACK flag has received.
func VerifySettingsFrameWithAck ¶
VerifySettingsFrameWithAck verifies whether a SETTINGS frame with ACK flag has received.
func VerifyStreamClose ¶
VerifyStreamClose verifies whether a stream close of HTTP/2 has occurred.
Types ¶
type ClientTestCase ¶
type ClientTestCase struct { Seq int Desc string Requirement string Parent *ClientTestGroup Result *ClientTestResult Run func(c *config.Config, conn *Conn) error Port int Done chan bool }
ClientTestCase represents a test case.
type ClientTestGroup ¶
type ClientTestGroup struct { Key string Section string Name string Parent *ClientTestGroup Groups []*ClientTestGroup Tests []*ClientTestCase PassedCount int FailedCount int SkippedCount int }
ClientTestGroup represents a group of test case.
func (*ClientTestGroup) AddTestCase ¶
func (tg *ClientTestGroup) AddTestCase(tc *ClientTestCase)
AddTestCase registers a test to this group.
func (*ClientTestGroup) AddTestGroup ¶
func (tg *ClientTestGroup) AddTestGroup(stg *ClientTestGroup)
AddTestGroup registers a group to this group.
func (*ClientTestGroup) ClientTestCases ¶
func (tg *ClientTestGroup) ClientTestCases(testCases map[int]*ClientTestCase, c *config.Config, currentPort int) int
func (*ClientTestGroup) ID ¶
func (tg *ClientTestGroup) ID() string
ID returns the unique ID of this group.
func (*ClientTestGroup) IncRecursive ¶
func (tg *ClientTestGroup) IncRecursive(failed bool, skipped bool, inc int)
func (*ClientTestGroup) IsRoot ¶
func (tg *ClientTestGroup) IsRoot() bool
IsRoot returns bool as to whether it is the parent of all groups.
func (*ClientTestGroup) Level ¶
func (tg *ClientTestGroup) Level() int
Level returns a number. Level is determined by Key and the number of "." included in Section.
func (*ClientTestGroup) Test ¶
func (tg *ClientTestGroup) Test(c *config.Config)
Test runs all the tests included in this group.
func (*ClientTestGroup) Title ¶
func (tg *ClientTestGroup) Title() string
Title returns the title of this group.
type ClientTestResult ¶
type ClientTestResult struct { ClientTestCase *ClientTestCase Error error Duration time.Duration Skipped bool Failed bool }
ClientTestResult represents a result of test case.
func NewClientTestResult ¶
func NewClientTestResult(tc *ClientTestCase, err error, d time.Duration) *ClientTestResult
NewClientTestResult returns a ClientTestResult.
func (*ClientTestResult) Print ¶
func (tr *ClientTestResult) Print()
Print prints the result of test case.
type Conn ¶
type Conn struct { net.Conn Settings map[http2.SettingID]uint32 Timeout time.Duration Verbose bool Closed bool WindowUpdate bool WindowSize map[uint32]int // contains filtered or unexported fields }
Conn represent a HTTP/2 connection. This struct contains settings information, current window size, encoder of HPACK and frame encoder.
func (*Conn) EncodeHeaders ¶
func (conn *Conn) EncodeHeaders(headers []hpack.HeaderField) []byte
EncodeHeaders encodes header and returns encoded bytes. Conn retains encoding context and next call of EncodeHeaders will be performed using the same encoding context.
func (*Conn) MaxFrameSize ¶
MaxFrameSize returns value of Handshake performs HTTP/2 handshake with the server.
func (*Conn) ReadClientPreface ¶
func (*Conn) ReadRequest ¶
func (*Conn) SetMaxDynamicTableSize ¶
SetMaxDynamicTableSize changes the dynamic header table size to v.
func (*Conn) WaitEvent ¶
WaitEvent returns a event occured on connection. This function is used to wait the next event on the connection.
func (*Conn) WaitEventByType ¶
WaitEventByType returns a specified event occured on connection. This function is used to wait the next event that has specified type on the connection.
func (*Conn) WriteContinuation ¶
func (conn *Conn) WriteContinuation(streamID uint32, endHeaders bool, headerBlockFragment []byte) error
WriteContinuation sends a CONTINUATION frame.
func (*Conn) WriteDataPadded ¶
WriteDataPadded sends a DATA frame with padding.
func (*Conn) WriteGoAway ¶
WriteGoAway sends a GOAWAY frame.
func (*Conn) WriteHeaders ¶
func (conn *Conn) WriteHeaders(p http2.HeadersFrameParam) error
WriteHeaders sends a HEADERS frame.
func (*Conn) WritePriority ¶
func (conn *Conn) WritePriority(streamID uint32, p http2.PriorityParam) error
WritePriority sends a PRIORITY frame.
func (*Conn) WritePushPromise ¶
func (conn *Conn) WritePushPromise(p http2.PushPromiseParam) error
WritePushPromise sends a PUSH_PROMISE frame.
func (*Conn) WriteRSTStream ¶
WriteRSTStream sends a RST_STREAM frame.
func (*Conn) WriteRawFrame ¶
func (*Conn) WriteSettings ¶
WriteSettings sends a SETTINGS frame.
func (*Conn) WriteSettingsAck ¶
WriteSettingsAck sends a SETTINGS frame with ACK flag.
func (*Conn) WriteSuccessResponse ¶
func (*Conn) WriteWindowUpdate ¶
WriteWindowUpdate sends a WINDOW_UPDATE frame.
type ConnectionClosedEvent ¶
type ConnectionClosedEvent struct{}
func (ConnectionClosedEvent) String ¶
func (ev ConnectionClosedEvent) String() string
func (ConnectionClosedEvent) Type ¶
func (ev ConnectionClosedEvent) Type() EventType
type ContinuationFrameEvent ¶
type ContinuationFrameEvent struct {
http2.ContinuationFrame
}
func (ContinuationFrameEvent) String ¶
func (ev ContinuationFrameEvent) String() string
func (ContinuationFrameEvent) Type ¶
func (ev ContinuationFrameEvent) Type() EventType
type DataFrameEvent ¶
func (DataFrameEvent) String ¶
func (ev DataFrameEvent) String() string
func (DataFrameEvent) Type ¶
func (ev DataFrameEvent) Type() EventType
type ErrorEvent ¶
type ErrorEvent struct {
Error error
}
func (ErrorEvent) String ¶
func (ev ErrorEvent) String() string
func (ErrorEvent) Type ¶
func (ev ErrorEvent) Type() EventType
type EventFrame ¶
type EventFrame interface { String() string Header() http2.FrameHeader }
type EventType ¶
type EventType uint8
const ( EventDataFrame EventType = 0x0 EventHeadersFrame EventType = 0x1 EventPriorityFrame EventType = 0x2 EventRSTStreamFrame EventType = 0x3 EventSettingsFrame EventType = 0x4 EventPushPromiseFrame EventType = 0x5 EventPingFrame EventType = 0x6 EventGoAwayFrame EventType = 0x7 EventWindowUpdateFrame EventType = 0x8 EventContinuationFrame EventType = 0x9 EventRawData EventType = 0x10 EventConnectionClosed EventType = 0x11 EventError EventType = 0x12 EventTimeout EventType = 0x13 )
type GoAwayFrameEvent ¶
type GoAwayFrameEvent struct {
http2.GoAwayFrame
}
func (GoAwayFrameEvent) String ¶
func (ev GoAwayFrameEvent) String() string
func (GoAwayFrameEvent) Type ¶
func (ev GoAwayFrameEvent) Type() EventType
type HeadersFrameEvent ¶
type HeadersFrameEvent struct {
http2.HeadersFrame
}
func (HeadersFrameEvent) String ¶
func (ev HeadersFrameEvent) String() string
func (HeadersFrameEvent) Type ¶
func (ev HeadersFrameEvent) Type() EventType
type PingFrameEvent ¶
func (PingFrameEvent) String ¶
func (ev PingFrameEvent) String() string
func (PingFrameEvent) Type ¶
func (ev PingFrameEvent) Type() EventType
type PriorityFrameEvent ¶
type PriorityFrameEvent struct {
http2.PriorityFrame
}
func (PriorityFrameEvent) String ¶
func (ev PriorityFrameEvent) String() string
func (PriorityFrameEvent) Type ¶
func (ev PriorityFrameEvent) Type() EventType
type PushPromiseFrameEvent ¶
type PushPromiseFrameEvent struct {
http2.PushPromiseFrame
}
func (PushPromiseFrameEvent) String ¶
func (ev PushPromiseFrameEvent) String() string
func (PushPromiseFrameEvent) Type ¶
func (ev PushPromiseFrameEvent) Type() EventType
type RSTStreamFrameEvent ¶
type RSTStreamFrameEvent struct {
http2.RSTStreamFrame
}
func (RSTStreamFrameEvent) String ¶
func (ev RSTStreamFrameEvent) String() string
func (RSTStreamFrameEvent) Type ¶
func (ev RSTStreamFrameEvent) Type() EventType
type RawDataEvent ¶
type RawDataEvent struct {
Payload []byte
}
func (RawDataEvent) String ¶
func (ev RawDataEvent) String() string
func (RawDataEvent) Type ¶
func (ev RawDataEvent) Type() EventType
type Request ¶
type Request struct { StreamID uint32 Headers []hpack.HeaderField }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) RunListener ¶
func (server *Server) RunListener(listener net.Listener, tc *ClientTestCase)
type SettingsFrameEvent ¶
type SettingsFrameEvent struct {
http2.SettingsFrame
}
func (SettingsFrameEvent) String ¶
func (ev SettingsFrameEvent) String() string
func (SettingsFrameEvent) Type ¶
func (ev SettingsFrameEvent) Type() EventType
type TestCase ¶
type TestCase struct { Desc string Requirement string Strict bool Parent *TestGroup Result *TestResult Run func(c *config.Config, conn *Conn) error }
TestCase represents a test case.
type TestGroup ¶
type TestGroup struct { Key string Section string Name string Strict bool Parent *TestGroup Groups []*TestGroup Tests []*TestCase StrictTests []*TestCase PassedCount int FailedCount int SkippedCount int }
TestGroup represents a group of test case.
func (*TestGroup) AddTestCase ¶
AddTestCase registers a test to this group.
func (*TestGroup) AddTestGroup ¶
AddTestGroup registers a group to this group.
func (*TestGroup) Level ¶
Level returns a number. Level is determined by Key and the number of "." included in Section.
type TestResult ¶
type TestResult struct { TestCase *TestCase Sequence int Error error Duration time.Duration SourceAddr net.Addr Skipped bool Failed bool }
TestResult represents a result of test case.
func NewTestResult ¶
NewTestResult returns a TestResult.
type TimeoutEvent ¶
type TimeoutEvent struct{}
func (TimeoutEvent) String ¶
func (ev TimeoutEvent) String() string
func (TimeoutEvent) Type ¶
func (ev TimeoutEvent) Type() EventType
type WindowUpdateFrameEvent ¶
type WindowUpdateFrameEvent struct {
http2.WindowUpdateFrame
}
func (WindowUpdateFrameEvent) String ¶
func (ev WindowUpdateFrameEvent) String() string
func (WindowUpdateFrameEvent) Type ¶
func (ev WindowUpdateFrameEvent) Type() EventType