github.com/psiphon-labs/psiphon-tunnel-core@v2.0.28+incompatible/psiphon/common/quic/gquic-go/h2quic/request_body.go (about)

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