http2: github.com/Jxck/http2/frame Index | Files

package frame

import "github.com/Jxck/http2/frame"

Index

Package Files

frame.go

Constants

const (
    DEFAULT_HEADER_TABLE_SIZE      int32 = 4096
    DEFAULT_ENABLE_PUSH                  = 1
    DEFAULT_MAX_CONCURRENT_STREAMS       = 2<<30 - 1 // actual infinite but 2^31-1 in this imple
    DEFAULT_INITIAL_WINDOW_SIZE          = 65535
    DEFAULT_MAX_FRAME_SIZE               = 16384
    DEFAULT_MAX_HEADER_LIST_SIZE         = 2<<30 - 1 // actual infinite but 2^31-1 in this imple
)

SETTINGS Frame

+-------------------------------+ | Identifier (16) | +-------------------------------+-------------------------------+ | Value (32) | +---------------------------------------------------------------+

Variables

var FrameMap = map[FrameType](func(*FrameHeader) Frame){
    DataFrameType:         func(fh *FrameHeader) Frame { return &DataFrame{FrameHeader: fh} },
    HeadersFrameType:      func(fh *FrameHeader) Frame { return &HeadersFrame{FrameHeader: fh} },
    PriorityFrameType:     func(fh *FrameHeader) Frame { return &PriorityFrame{FrameHeader: fh} },
    RstStreamFrameType:    func(fh *FrameHeader) Frame { return &RstStreamFrame{FrameHeader: fh} },
    SettingsFrameType:     func(fh *FrameHeader) Frame { return &SettingsFrame{FrameHeader: fh} },
    PushPromiseFrameType:  func(fh *FrameHeader) Frame { return &PushPromiseFrame{FrameHeader: fh} },
    PingFrameType:         func(fh *FrameHeader) Frame { return &PingFrame{FrameHeader: fh} },
    GoAwayFrameType:       func(fh *FrameHeader) Frame { return &GoAwayFrame{FrameHeader: fh} },
    WindowUpdateFrameType: func(fh *FrameHeader) Frame { return &WindowUpdateFrame{FrameHeader: fh} },
    ContinuationFrameType: func(fh *FrameHeader) Frame { return &ContinuationFrame{FrameHeader: fh} },
}

map of FrameType and FrameInitializer

type ContinuationFrame Uses

type ContinuationFrame struct {
    *FrameHeader
    Headers             http.Header
    HeaderBlockFragment []byte
}

CONTINUATION

+---------------------------------------------------------------+ | Header Block Fragment (*) ... +---------------------------------------------------------------+

func NewContinuationFrame Uses

func NewContinuationFrame(flags Flag, streamID uint32, headerBlockFragment []byte) *ContinuationFrame

func (*ContinuationFrame) Header Uses

func (frame *ContinuationFrame) Header() *FrameHeader

func (*ContinuationFrame) Read Uses

func (frame *ContinuationFrame) Read(r io.Reader) (err error)

func (*ContinuationFrame) String Uses

func (frame *ContinuationFrame) String() string

func (*ContinuationFrame) Write Uses

func (frame *ContinuationFrame) Write(w io.Writer) (err error)

type DataFrame Uses

type DataFrame struct {
    *FrameHeader
    PadLength uint8
    Data      []byte
    Padding   []byte
}

DATA

+---------------+ |Pad Length? (8)| +---------------+-----------------------------------------------+ | Data (*) ... +---------------------------------------------------------------+ | Padding (*) ... +---------------------------------------------------------------+

func NewDataFrame Uses

func NewDataFrame(flags Flag, streamID uint32, data []byte, padding []byte) *DataFrame

func (*DataFrame) Header Uses

func (frame *DataFrame) Header() *FrameHeader

func (*DataFrame) Read Uses

func (frame *DataFrame) Read(r io.Reader) (err error)

func (*DataFrame) String Uses

func (frame *DataFrame) String() string

func (*DataFrame) Write Uses

func (frame *DataFrame) Write(w io.Writer) (err error)

type DependencyTree Uses

type DependencyTree struct {
    Exclusive        bool
    StreamDependency uint32
    Weight           uint8
}

type ErrorCode Uses

type ErrorCode uint32

For RST_STREAM and GOAWAY Frame

const (
    NO_ERROR            ErrorCode = 0x0
    PROTOCOL_ERROR      ErrorCode = 0x1
    INTERNAL_ERROR      ErrorCode = 0x2
    FLOW_CONTROL_ERROR  ErrorCode = 0x3
    SETTINGS_TIMEOUT    ErrorCode = 0x4
    STREAM_CLOSED       ErrorCode = 0x5
    FRAME_SIZE_ERROR    ErrorCode = 0x6
    REFUSED_STREAM      ErrorCode = 0x7
    CANCEL              ErrorCode = 0x8
    COMPRESSION_ERROR   ErrorCode = 0x9
    CONNECT_ERROR       ErrorCode = 0xa
    ENHANCE_YOUR_CALM   ErrorCode = 0xb
    INADEQUATE_SECURITY ErrorCode = 0xc
    HTTP_1_1_REQUIRED   ErrorCode = 0xd
)

func (ErrorCode) String Uses

func (e ErrorCode) String() string

type Flag Uses

type Flag uint8

Flags

const (
    UNSET       Flag = 0x0
    END_STREAM       = 0x1
    ACK              = 0x1 // for settings
    END_HEADERS      = 0x4
    PADDED           = 0x8
    PRIORITY         = 0x20
)

type Frame Uses

type Frame interface {
    Write(w io.Writer) error
    Read(r io.Reader) error
    Header() *FrameHeader
    String() string
}

func ReadFrame Uses

func ReadFrame(r io.Reader, settings map[SettingsID]int32) (frame Frame, err error)

Read

type FrameHeader Uses

type FrameHeader struct {
    Length            uint32 // 24bit
    Type              FrameType
    Flags             Flag
    StreamID          uint32 // R+31bit
    MaxFrameSize      int32
    MaxHeaderListSize int32
}

Frame Header

+-----------------------------------------------+ | Length (24) | +---------------+---------------+---------------+ | Type (8) | Flags (8) | +-+-------------+---------------+-------------------------------+ |R| Stream Identifier (31) | +=+=============================================================+ | Frame Payload (0...) ... +---------------------------------------------------------------+

func NewFrameHeader Uses

func NewFrameHeader(length uint32, types FrameType, flags Flag, streamid uint32) *FrameHeader

func (*FrameHeader) Read Uses

func (fh *FrameHeader) Read(r io.Reader) (err error)

func (*FrameHeader) String Uses

func (fh *FrameHeader) String() string

func (*FrameHeader) Write Uses

func (fh *FrameHeader) Write(w io.Writer) (err error)

type FrameType Uses

type FrameType uint8
const (
    DataFrameType         FrameType = 0x0
    HeadersFrameType                = 0x1
    PriorityFrameType               = 0x2
    RstStreamFrameType              = 0x3
    SettingsFrameType               = 0x4
    PushPromiseFrameType            = 0x5
    PingFrameType                   = 0x6
    GoAwayFrameType                 = 0x7
    WindowUpdateFrameType           = 0x8
    ContinuationFrameType           = 0x9
)

func (FrameType) String Uses

func (frameType FrameType) String() string

type GoAwayFrame Uses

type GoAwayFrame struct {
    *FrameHeader
    LastStreamID        uint32
    ErrorCode           ErrorCode
    AdditionalDebugData []byte
}

GOAWAY

+-+-------------------------------------------------------------+ |R| Last-Stream-ID (31) | +-+-------------------------------------------------------------+ | Error Code (32) | +---------------------------------------------------------------+ | Additional Debug Data (*) | +---------------------------------------------------------------+

func NewGoAwayFrame Uses

func NewGoAwayFrame(streamID uint32, lastStreamID uint32, errorCode ErrorCode, additionalDebugData []byte) *GoAwayFrame

func (*GoAwayFrame) Header Uses

func (frame *GoAwayFrame) Header() *FrameHeader

func (*GoAwayFrame) Read Uses

func (frame *GoAwayFrame) Read(r io.Reader) (err error)

func (*GoAwayFrame) String Uses

func (frame *GoAwayFrame) String() string

func (*GoAwayFrame) Write Uses

func (frame *GoAwayFrame) Write(w io.Writer) (err error)

type H2Error Uses

type H2Error struct {
    ErrorCode           ErrorCode
    AdditiolanDebugData string
}

func (H2Error) Error Uses

func (e H2Error) Error() string

func (H2Error) String Uses

func (e H2Error) String() string

type HeadersFrame Uses

type HeadersFrame struct {
    *FrameHeader
    PadLength           uint8
    DependencyTree      *DependencyTree
    HeaderBlockFragment []byte
    Headers             http.Header
    Padding             []byte
}

HEADERS

+---------------+ |Pad Length? (8)| +-+-------------+-----------------------------------------------+ |E| Stream Dependency? (31) | +-+-------------+-----------------------------------------------+ | Weight? (8) | +-+-------------+-----------------------------------------------+ | Header Block Fragment (*) ... +---------------------------------------------------------------+ | Padding (*) ... +---------------------------------------------------------------+

func NewHeadersFrame Uses

func NewHeadersFrame(flags Flag, streamID uint32, dependencyTree *DependencyTree, headerBlockFragment []byte, padding []byte) *HeadersFrame

func (*HeadersFrame) Header Uses

func (frame *HeadersFrame) Header() *FrameHeader

func (*HeadersFrame) Read Uses

func (frame *HeadersFrame) Read(r io.Reader) (err error)

func (*HeadersFrame) String Uses

func (frame *HeadersFrame) String() string

func (*HeadersFrame) Write Uses

func (frame *HeadersFrame) Write(w io.Writer) (err error)

type PingFrame Uses

type PingFrame struct {
    *FrameHeader
    OpaqueData []byte
}

PING

+---------------------------------------------------------------+ | | | Opaque Data (64) | | | +---------------------------------------------------------------+

func NewPingFrame Uses

func NewPingFrame(flags Flag, streamID uint32, opaqueData []byte) *PingFrame

func (*PingFrame) Header Uses

func (frame *PingFrame) Header() *FrameHeader

func (*PingFrame) Read Uses

func (frame *PingFrame) Read(r io.Reader) (err error)

func (*PingFrame) String Uses

func (frame *PingFrame) String() string

func (*PingFrame) Write Uses

func (frame *PingFrame) Write(w io.Writer) (err error)

type PriorityFrame Uses

type PriorityFrame struct {
    *FrameHeader
    Exclusive        bool
    StreamDependency uint32
    Weight           uint8
}

PRIORITY

+-+-------------------------------------------------------------+ |E| Stream Dependency (31) | +-+-------------+-----------------------------------------------+ | Weight (8) | +-+-------------+

func NewPriorityFrame Uses

func NewPriorityFrame(streamID uint32, exclusive bool, streamDependency uint32, weight uint8) *PriorityFrame

func (*PriorityFrame) Header Uses

func (frame *PriorityFrame) Header() *FrameHeader

func (*PriorityFrame) Read Uses

func (frame *PriorityFrame) Read(r io.Reader) (err error)

func (*PriorityFrame) String Uses

func (frame *PriorityFrame) String() string

func (*PriorityFrame) Write Uses

func (frame *PriorityFrame) Write(w io.Writer) (err error)

type PushPromiseFrame Uses

type PushPromiseFrame struct {
    *FrameHeader
    PadLength           uint8
    PromisedStreamID    uint32
    HeaderBlockFragment []byte
    Padding             []byte
}

PUSH_PROMISE

+---------------+ |Pad Length? (8)| +-+-------------+-----------------------------------------------+ |R| Promised Stream ID (31) | +-+-----------------------------+-------------------------------+ | Header Block Fragment (*) ... +---------------------------------------------------------------+ | Padding (*) ... +---------------------------------------------------------------+

func NewPushPromiseFrame Uses

func NewPushPromiseFrame(flags Flag, streamID, promisedStreamID uint32, headerBlockFragment, padding []byte) *PushPromiseFrame

func (*PushPromiseFrame) Header Uses

func (frame *PushPromiseFrame) Header() *FrameHeader

func (*PushPromiseFrame) Read Uses

func (frame *PushPromiseFrame) Read(r io.Reader) (err error)

func (*PushPromiseFrame) String Uses

func (frame *PushPromiseFrame) String() string

func (*PushPromiseFrame) Write Uses

func (frame *PushPromiseFrame) Write(w io.Writer) (err error)

type RstStreamFrame Uses

type RstStreamFrame struct {
    *FrameHeader
    ErrorCode ErrorCode
}

RST_STREAM

+---------------------------------------------------------------+ | Error Code (32) | +---------------------------------------------------------------+

func NewRstStreamFrame Uses

func NewRstStreamFrame(streamID uint32, errorCode ErrorCode) *RstStreamFrame

func (*RstStreamFrame) Header Uses

func (frame *RstStreamFrame) Header() *FrameHeader

func (*RstStreamFrame) Read Uses

func (frame *RstStreamFrame) Read(r io.Reader) (err error)

func (*RstStreamFrame) String Uses

func (frame *RstStreamFrame) String() string

func (*RstStreamFrame) Write Uses

func (frame *RstStreamFrame) Write(w io.Writer) (err error)

type SettingsFrame Uses

type SettingsFrame struct {
    *FrameHeader
    Settings map[SettingsID]int32
}

func NewSettingsFrame Uses

func NewSettingsFrame(flags Flag, streamID uint32, settings map[SettingsID]int32) *SettingsFrame

func (*SettingsFrame) Header Uses

func (frame *SettingsFrame) Header() *FrameHeader

func (*SettingsFrame) Read Uses

func (frame *SettingsFrame) Read(r io.Reader) (err error)

func (*SettingsFrame) String Uses

func (frame *SettingsFrame) String() string

func (*SettingsFrame) Write Uses

func (frame *SettingsFrame) Write(w io.Writer) (err error)

type SettingsID Uses

type SettingsID uint16
const (
    SETTINGS_HEADER_TABLE_SIZE      SettingsID = 0x1 // 4096
    SETTINGS_ENABLE_PUSH                       = 0x2 // 1
    SETTINGS_MAX_CONCURRENT_STREAMS            = 0x3 // (infinite)
    SETTINGS_INITIAL_WINDOW_SIZE               = 0x4 // 65535
    SETTINGS_MAX_FRAME_SIZE                    = 0x5 // 65536
    SETTINGS_MAX_HEADER_LIST_SIZE              = 0x6 // (infinite)
)

func (SettingsID) String Uses

func (s SettingsID) String() string

type WindowUpdateFrame Uses

type WindowUpdateFrame struct {
    *FrameHeader
    WindowSizeIncrement uint32
}

WINDOW_UPDATE

+-+-------------------------------------------------------------+ |R| Window Size Increment (31) | +-+-------------------------------------------------------------+

func NewWindowUpdateFrame Uses

func NewWindowUpdateFrame(streamID, incrementSize uint32) *WindowUpdateFrame

func (*WindowUpdateFrame) Header Uses

func (frame *WindowUpdateFrame) Header() *FrameHeader

func (*WindowUpdateFrame) Read Uses

func (frame *WindowUpdateFrame) Read(r io.Reader) (err error)

func (*WindowUpdateFrame) String Uses

func (frame *WindowUpdateFrame) String() string

func (*WindowUpdateFrame) Write Uses

func (frame *WindowUpdateFrame) Write(w io.Writer) (err error)

Package frame imports 8 packages (graph) and is imported by 1 packages. Updated 2016-07-21. Refresh now. Tools for package owners.