(p []byte)
| 455 | } |
| 456 | |
| 457 | func (mr *msgReader) read(p []byte) (int, error) { |
| 458 | for { |
| 459 | if mr.payloadLength == 0 { |
| 460 | if mr.fin { |
| 461 | if mr.flate { |
| 462 | return mr.flateTail.Read(p) |
| 463 | } |
| 464 | return 0, io.EOF |
| 465 | } |
| 466 | |
| 467 | h, err := mr.c.readLoop(mr.ctx) |
| 468 | if err != nil { |
| 469 | return 0, err |
| 470 | } |
| 471 | if h.opcode != opContinuation { |
| 472 | err := errors.New("received new data message without finishing the previous message") |
| 473 | mr.c.writeError(StatusProtocolError, err) |
| 474 | return 0, err |
| 475 | } |
| 476 | mr.setFrame(h) |
| 477 | |
| 478 | continue |
| 479 | } |
| 480 | |
| 481 | if int64(len(p)) > mr.payloadLength { |
| 482 | p = p[:mr.payloadLength] |
| 483 | } |
| 484 | |
| 485 | n, err := mr.c.readFramePayload(mr.ctx, p) |
| 486 | if err != nil { |
| 487 | return n, err |
| 488 | } |
| 489 | |
| 490 | mr.payloadLength -= int64(n) |
| 491 | |
| 492 | if !mr.c.client { |
| 493 | mr.maskKey = mask(p, mr.maskKey) |
| 494 | } |
| 495 | |
| 496 | return n, nil |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | type limitReader struct { |
| 501 | c *Conn |
nothing calls this directly
no test coverage detected