Skip to content

Commit 6fa393c

Browse files
authored
transport/grpchttp2: add doc to methods and values (#7445)
1 parent 1013847 commit 6fa393c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

internal/transport/grpchttp2/errors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import "fmt"
3030
// [GOAWAY]: https://httpwg.org/specs/rfc7540.html#GOAWAY
3131
type ErrCode uint32
3232

33+
// Error Codes defined by the HTTP/2 Spec.
3334
const (
3435
ErrCodeNoError ErrCode = 0x0
3536
ErrCodeProtocol ErrCode = 0x1

internal/transport/grpchttp2/framer.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import "golang.org/x/net/http2/hpack"
2727
// [Frame Type]: https://httpwg.org/specs/rfc7540.html#FrameType
2828
type FrameType uint8
2929

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

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

73+
// Setting IDs defined in the HTTP/2 Spec.
7174
const (
7275
SettingsHeaderTableSize SettingID = 0x1
7376
SettingsEnablePush SettingID = 0x2
@@ -121,10 +124,12 @@ type DataFrame struct {
121124
Data []byte
122125
}
123126

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)