Skip to content

Commit

Permalink
transport/grpchttp2: add doc to methods and values (#7445)
Browse files Browse the repository at this point in the history
  • Loading branch information
printchard authored Jul 31, 2024
1 parent 1013847 commit 6fa393c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/transport/grpchttp2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import "fmt"
// [GOAWAY]: https://httpwg.org/specs/rfc7540.html#GOAWAY
type ErrCode uint32

// Error Codes defined by the HTTP/2 Spec.
const (
ErrCodeNoError ErrCode = 0x0
ErrCodeProtocol ErrCode = 0x1
Expand Down
20 changes: 20 additions & 0 deletions internal/transport/grpchttp2/framer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import "golang.org/x/net/http2/hpack"
// [Frame Type]: https://httpwg.org/specs/rfc7540.html#FrameType
type FrameType uint8

// Frame types defined in the HTTP/2 Spec.
const (
FrameTypeData FrameType = 0x0
FrameTypeHeaders FrameType = 0x1
Expand All @@ -41,6 +42,7 @@ const (
// Flag represents one or more flags set on an HTTP/2 Frame.
type Flag uint8

// Flags defined in the HTTP/2 Spec.
const (
FlagDataEndStream Flag = 0x1
FlagDataPadded Flag = 0x8
Expand Down Expand Up @@ -68,6 +70,7 @@ type Setting struct {
// [Setting Values]: https://httpwg.org/specs/rfc7540.html#SettingValues
type SettingID uint16

// Setting IDs defined in the HTTP/2 Spec.
const (
SettingsHeaderTableSize SettingID = 0x1
SettingsEnablePush SettingID = 0x2
Expand Down Expand Up @@ -121,10 +124,12 @@ type DataFrame struct {
Data []byte
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *DataFrame) Header() *FrameHeader {
return f.hdr
}

// Free frees the buffer containing the data in this frame.
func (f *DataFrame) Free() {
if f.free != nil {
f.free()
Expand All @@ -141,10 +146,12 @@ type HeadersFrame struct {
HdrBlock []byte
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *HeadersFrame) Header() *FrameHeader {
return f.hdr
}

// Free frees the buffer containing the header block in this frame.
func (f *HeadersFrame) Free() {
if f.free != nil {
f.free()
Expand All @@ -161,10 +168,12 @@ type RSTStreamFrame struct {
Code ErrCode
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *RSTStreamFrame) Header() *FrameHeader {
return f.hdr
}

// Free is a no-op for RSTStreamFrame.
func (f *RSTStreamFrame) Free() {}

// SettingsFrame is the representation of a [SETTINGS Frame]. There is no
Expand All @@ -179,10 +188,12 @@ type SettingsFrame struct {
Settings []Setting
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *SettingsFrame) Header() *FrameHeader {
return f.hdr
}

// Free is a no-op for SettingsFrame.
func (f *SettingsFrame) Free() {}

// PingFrame is the representation of a [PING Frame]. The PING frame is a
Expand All @@ -196,10 +207,12 @@ type PingFrame struct {
Data []byte
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *PingFrame) Header() *FrameHeader {
return f.hdr
}

// Free frees the buffer containing the data in this frame.
func (f *PingFrame) Free() {
if f.free != nil {
f.free()
Expand All @@ -219,10 +232,12 @@ type GoAwayFrame struct {
DebugData []byte
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *GoAwayFrame) Header() *FrameHeader {
return f.hdr
}

// Free frees the buffer containing the debug data in this frame.
func (f *GoAwayFrame) Free() {
if f.free != nil {
f.free()
Expand All @@ -238,6 +253,7 @@ type WindowUpdateFrame struct {
Inc uint32
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *WindowUpdateFrame) Header() *FrameHeader {
return f.hdr
}
Expand All @@ -252,10 +268,12 @@ type ContinuationFrame struct {
HdrBlock []byte
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *ContinuationFrame) Header() *FrameHeader {
return f.hdr
}

// Free frees the buffer containing the header block in this frame.
func (f *ContinuationFrame) Free() {
if f.free != nil {
f.free()
Expand All @@ -276,10 +294,12 @@ type MetaHeadersFrame struct {
Truncated bool
}

// Header returns the 9 byte HTTP/2 header for this frame.
func (f *MetaHeadersFrame) Header() *FrameHeader {
return f.hdr
}

// Free is a no-op for MetaHeadersFrame.
func (f *MetaHeadersFrame) Free() {}

// Framer encapsulates the functionality to read and write HTTP/2 frames.
Expand Down

0 comments on commit 6fa393c

Please sign in to comment.