(t *testing.T)
| 323 | } |
| 324 | |
| 325 | func (s) TestFramer_ParseDataFrame(t *testing.T) { |
| 326 | tests := []struct { |
| 327 | name string |
| 328 | wire []byte // from frame header onward |
| 329 | wantData []byte |
| 330 | wantErr error |
| 331 | wantErrDetailSubstr string |
| 332 | }{ |
| 333 | { |
| 334 | name: "good_padded", |
| 335 | wire: buildDataFrame(http2.FrameHeader{ |
| 336 | Type: http2.FrameData, Length: 6, StreamID: 1, Flags: http2.FlagDataPadded, |
| 337 | }, []byte{ |
| 338 | 2, // pad length |
| 339 | 'f', 'o', 'o', // data |
| 340 | 0, 0, // padding |
| 341 | }), |
| 342 | wantData: []byte("foo"), |
| 343 | }, |
| 344 | { |
| 345 | name: "good_unpadded", |
| 346 | wire: buildDataFrame(http2.FrameHeader{ |
| 347 | Type: http2.FrameData, Length: 3, StreamID: 1, Flags: 0, |
| 348 | }, []byte("foo")), |
| 349 | wantData: []byte("foo"), |
| 350 | }, |
| 351 | { |
| 352 | name: "stream_id_0", |
| 353 | wire: buildDataFrame(http2.FrameHeader{ |
| 354 | Type: http2.FrameData, Length: 1, StreamID: 0, Flags: 0, |
| 355 | }, []byte{0}), |
| 356 | wantErr: http2.ConnectionError(http2.ErrCodeProtocol), |
| 357 | wantErrDetailSubstr: "DATA frame with stream ID 0", |
| 358 | }, |
| 359 | { |
| 360 | name: "pad_size_bigger_than_payload", |
| 361 | wire: buildDataFrame(http2.FrameHeader{ |
| 362 | Type: http2.FrameData, Length: 4, StreamID: 1, Flags: http2.FlagDataPadded, |
| 363 | }, []byte{ |
| 364 | 4, // pad length of 4 |
| 365 | 'f', 'o', // data 'fo' is 2 bytes |
| 366 | 0, // padding 0 is 1 byte. |
| 367 | }), // pad length 4 but only 3 bytes for data+padding available in payload after pad length byte |
| 368 | wantErr: http2.ConnectionError(http2.ErrCodeProtocol), |
| 369 | wantErrDetailSubstr: "pad size larger than data payload", |
| 370 | }, |
| 371 | { |
| 372 | name: "padded_zero_data_some_padding", |
| 373 | wire: buildDataFrame(http2.FrameHeader{ |
| 374 | Type: http2.FrameData, Length: 3, StreamID: 1, Flags: http2.FlagDataPadded, |
| 375 | }, []byte{ |
| 376 | 2, // pad length 2 |
| 377 | 0, 0, // padding |
| 378 | }), |
| 379 | wantData: []byte{}, |
| 380 | }, |
| 381 | { |
| 382 | name: "padded_short_payload_reading_pad_flag", |
nothing calls this directly
no test coverage detected