48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
|
//go:build plus
|
|
|
|
package http3
|
|
|
|
import (
|
|
"github.com/quic-go/quic-go"
|
|
"time"
|
|
)
|
|
|
|
type ReceiveStream struct {
|
|
rawReceiveStream quic.ReceiveStream
|
|
conn Conn
|
|
}
|
|
|
|
func NewReceiveStream(rawReceiveStream quic.ReceiveStream, conn Conn) *ReceiveStream {
|
|
return &ReceiveStream{
|
|
rawReceiveStream: rawReceiveStream,
|
|
conn: conn,
|
|
}
|
|
}
|
|
|
|
func (this *ReceiveStream) StreamID() quic.StreamID {
|
|
return this.rawReceiveStream.StreamID()
|
|
}
|
|
|
|
func (this *ReceiveStream) CancelRead(errorCode quic.StreamErrorCode) {
|
|
this.rawReceiveStream.CancelRead(errorCode)
|
|
}
|
|
|
|
func (this *ReceiveStream) SetReadDeadline(t time.Time) error {
|
|
return this.rawReceiveStream.SetReadDeadline(t)
|
|
}
|
|
|
|
func (this *ReceiveStream) Read(p []byte) (n int, err error) {
|
|
n, err = this.rawReceiveStream.Read(p)
|
|
|
|
// notify
|
|
if n > 0 && this.conn != nil {
|
|
var notifier = this.conn.notifier()
|
|
if notifier != nil {
|
|
notifier.ReadBytes(n)
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|