1.4.5.2
This commit is contained in:
47
EdgeNode/internal/http3/stream_receive.go
Normal file
47
EdgeNode/internal/http3/stream_receive.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user