mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-11-01 07:57:03 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bae46b1c0 |
@@ -71,6 +71,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, sessio
|
||||
errors.LogInfoInner(ctx, err, "failed to "+method+" "+url)
|
||||
}
|
||||
gotConn.Close()
|
||||
common.Close(body)
|
||||
wrc.Close()
|
||||
return
|
||||
}
|
||||
@@ -80,6 +81,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, sessio
|
||||
if resp.StatusCode != 200 || uploadOnly { // stream-up
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close() // if it is called immediately, the upload will be interrupted also
|
||||
common.Close(body)
|
||||
wrc.Close()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -183,8 +183,6 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea
|
||||
if quicParams.KeepAlivePeriod == 0 {
|
||||
if keepAlivePeriod == 0 {
|
||||
quicConfig.KeepAlivePeriod = net.QuicgoH3KeepAlivePeriod
|
||||
} else if keepAlivePeriod > 0 {
|
||||
quicConfig.KeepAlivePeriod = keepAlivePeriod
|
||||
}
|
||||
}
|
||||
if quicParams.MaxIncomingStreams == 0 {
|
||||
@@ -508,8 +506,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
||||
var seq int64
|
||||
var lastWrite time.Time
|
||||
|
||||
dynamicHTTPClient := httpClient
|
||||
dynamicXmuxClient := xmuxClient
|
||||
for {
|
||||
// by offloading the uploads into a buffered pipe, multiple conn.Write
|
||||
// calls get automatically batched together into larger POST requests.
|
||||
@@ -544,13 +540,13 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
||||
|
||||
lastWrite = time.Now()
|
||||
|
||||
if dynamicXmuxClient != nil && (dynamicXmuxClient.LeftRequests.Add(-1) <= 0 ||
|
||||
(dynamicXmuxClient.UnreusableAt != time.Time{} && lastWrite.After(dynamicXmuxClient.UnreusableAt))) {
|
||||
dynamicHTTPClient, dynamicXmuxClient = getHTTPClient(ctx, dest, streamSettings)
|
||||
if xmuxClient != nil && (xmuxClient.LeftRequests.Add(-1) <= 0 ||
|
||||
(xmuxClient.UnreusableAt != time.Time{} && lastWrite.After(xmuxClient.UnreusableAt))) {
|
||||
httpClient, xmuxClient = getHTTPClient(ctx, dest, streamSettings)
|
||||
}
|
||||
|
||||
go func(hClient DialerClient) {
|
||||
err := hClient.PostPacket(
|
||||
go func() {
|
||||
err := httpClient.PostPacket(
|
||||
ctx,
|
||||
requestURL.String(),
|
||||
sessionId,
|
||||
@@ -563,9 +559,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
||||
uploadPipeReader.Interrupt()
|
||||
doSplit.Store(false)
|
||||
}
|
||||
}(dynamicHTTPClient)
|
||||
}()
|
||||
|
||||
if _, ok := dynamicHTTPClient.(*DefaultDialerClient); ok {
|
||||
if _, ok := httpClient.(*DefaultDialerClient); ok {
|
||||
<-wroteRequest.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user