Initial commit (code only without large binaries)
This commit is contained in:
60
EdgeNode/internal/http3/stream_send.go
Normal file
60
EdgeNode/internal/http3/stream_send.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build plus
|
||||
|
||||
package http3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/quic-go/quic-go"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SendStream struct {
|
||||
rawSendStream quic.SendStream
|
||||
conn Conn
|
||||
}
|
||||
|
||||
func NewSendStream(rawSendStream quic.SendStream, conn Conn) *SendStream {
|
||||
return &SendStream{
|
||||
rawSendStream: rawSendStream,
|
||||
conn: conn,
|
||||
}
|
||||
}
|
||||
|
||||
func (this *SendStream) StreamID() quic.StreamID {
|
||||
return this.rawSendStream.StreamID()
|
||||
}
|
||||
|
||||
func (this *SendStream) CancelWrite(errorCode quic.StreamErrorCode) {
|
||||
this.rawSendStream.CancelWrite(errorCode)
|
||||
}
|
||||
|
||||
func (this *SendStream) Context() context.Context {
|
||||
var ctx = this.rawSendStream.Context()
|
||||
if this.conn != nil {
|
||||
ctx = this.conn.callContextFunc(ctx)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func (this *SendStream) SetWriteDeadline(t time.Time) error {
|
||||
return this.rawSendStream.SetWriteDeadline(t)
|
||||
}
|
||||
|
||||
func (this *SendStream) Write(p []byte) (n int, err error) {
|
||||
n, err = this.rawSendStream.Write(p)
|
||||
|
||||
// notify
|
||||
if n > 0 && this.conn != nil {
|
||||
var notifier = this.conn.notifier()
|
||||
if notifier != nil {
|
||||
notifier.WriteBytes(n)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *SendStream) Close() error {
|
||||
return this.rawSendStream.Close()
|
||||
}
|
||||
Reference in New Issue
Block a user