request_body.go 570 B

1234567891011121314151617181920212223242526272829
  1. package h2quic
  2. import (
  3. "io"
  4. quic "github.com/lucas-clemente/quic-go"
  5. )
  6. type requestBody struct {
  7. requestRead bool
  8. dataStream quic.Stream
  9. }
  10. // make sure the requestBody can be used as a http.Request.Body
  11. var _ io.ReadCloser = &requestBody{}
  12. func newRequestBody(stream quic.Stream) *requestBody {
  13. return &requestBody{dataStream: stream}
  14. }
  15. func (b *requestBody) Read(p []byte) (int, error) {
  16. b.requestRead = true
  17. return b.dataStream.Read(p)
  18. }
  19. func (b *requestBody) Close() error {
  20. // stream's Close() closes the write side, not the read side
  21. return nil
  22. }