This commit is contained in:
wjqserver 2025-06-14 06:51:41 +08:00
parent d2a0177015
commit bd8412f157
2 changed files with 11 additions and 10 deletions

View file

@ -1 +1 @@
25w46a 25w46b

View file

@ -1,7 +1,6 @@
package proxy package proxy
import ( import (
"bytes"
"context" "context"
"fmt" "fmt"
"ghproxy/config" "ghproxy/config"
@ -33,8 +32,8 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
rb := client.NewRequestBuilder(string(c.Request.Method()), u) rb := client.NewRequestBuilder(string(c.Request.Method()), u)
rb.NoDefaultHeaders() rb.NoDefaultHeaders()
rb.SetBody(bytes.NewBuffer(c.Request.Body())) //rb.SetBody(bytes.NewBuffer(c.Request.Body()))
//rb.SetBody(c.RequestBodyStream()) rb.SetBody(c.RequestBodyStream())
rb.WithContext(ctx) rb.WithContext(ctx)
req, err = rb.Build() req, err = rb.Build()
@ -112,12 +111,14 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
bodyReader = limitreader.NewRateLimitedReader(bodyReader, bandwidthLimit, int(bandwidthBurst), ctx) bodyReader = limitreader.NewRateLimitedReader(bodyReader, bandwidthLimit, int(bandwidthBurst), ctx)
} }
defer func() { /*
err := bodyReader.Close() defer func() {
if err != nil { err := bodyReader.Close()
logError("Failed to close response body: %v", err) if err != nil {
} logError("Failed to close response body: %v", err)
}() }
}()
*/
if MatcherShell(u) && matchString(matcher) && cfg.Shell.Editor { if MatcherShell(u) && matchString(matcher) && cfg.Shell.Editor {
// 判断body是不是gzip // 判断body是不是gzip