XHTTP server: Add scStreamUpServerSecs, enabled by default (#4306)

Fixes https://github.com/XTLS/Xray-core/discussions/4113#discussioncomment-11682833
This commit is contained in:
RPRX 2025-01-19 13:32:07 +00:00 committed by GitHub
parent f4fd8b8fad
commit ca9a902213
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 123 additions and 97 deletions

View file

@ -60,7 +60,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, body i
method = "POST" // stream-up/one
}
req, _ := http.NewRequestWithContext(context.WithoutCancel(ctx), method, url, body)
req.Header = c.transportConfig.GetRequestHeader()
req.Header = c.transportConfig.GetRequestHeader(url)
if method == "POST" && !c.transportConfig.NoGRPCHeader {
req.Header.Set("Content-Type", "application/grpc")
}
@ -69,10 +69,10 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, body i
go func() {
resp, err := c.client.Do(req)
if err != nil {
if !uploadOnly {
if !uploadOnly { // stream-down is enough
c.closed = true
errors.LogInfoInner(ctx, err, "failed to "+method+" "+url)
}
errors.LogInfoInner(ctx, err, "failed to "+method+" "+url)
gotConn.Close()
wrc.Close()
return
@ -99,7 +99,7 @@ func (c *DefaultDialerClient) PostPacket(ctx context.Context, url string, body i
return err
}
req.ContentLength = contentLength
req.Header = c.transportConfig.GetRequestHeader()
req.Header = c.transportConfig.GetRequestHeader(url)
if c.httpVersion != "1.1" {
resp, err := c.client.Do(req)