Close http3 correctly

This commit is contained in:
Fangliding
2026-06-17 03:17:37 +08:00
parent da21a8f77f
commit 06306a2bcc
4 changed files with 39 additions and 9 deletions
+10
View File
@@ -9,6 +9,7 @@ import (
"net/http/httptrace"
"sync"
"github.com/apernet/quic-go/http3"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
@@ -172,6 +173,15 @@ func (c *DefaultDialerClient) PostPacket(ctx context.Context, url string, sessio
return nil
}
// HTTP/1.1 and HTTP/2 will close itself, we only handle HTTP/3 here
func (c *DefaultDialerClient) Close() error {
transport := c.client.Transport
if h3Transport, ok := transport.(*http3.Transport); ok {
h3Transport.Close()
}
return nil
}
type WaitReadCloser struct {
Wait chan struct{}
io.ReadCloser