diff --git a/proxy/chunkreq.go b/proxy/chunkreq.go index b02ec4c..18cc0cb 100644 --- a/proxy/chunkreq.go +++ b/proxy/chunkreq.go @@ -1,7 +1,6 @@ package proxy import ( - "bytes" "context" "fmt" "ghproxy/config" @@ -38,17 +37,17 @@ var ( func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, cfg *config.Config, matcher string) { var ( - method []byte - bodyReader *bytes.Buffer - req *http.Request - resp *http.Response - err error + method []byte + //bodyReader *bytes.Buffer + req *http.Request + resp *http.Response + err error ) method = c.Request.Method() - bodyReader = bytes.NewBuffer(c.Request.Body()) + //bodyReader = bytes.NewBuffer(c.Request.Body()) - req, err = client.NewRequest(string(method), u, bodyReader) + req, err = client.NewRequest(string(method), u, c.Request.BodyStream()) if err != nil { HandleError(c, fmt.Sprintf("Failed to create request: %v", err)) return diff --git a/proxy/gitreq.go b/proxy/gitreq.go index 55ede9a..ad53f94 100644 --- a/proxy/gitreq.go +++ b/proxy/gitreq.go @@ -1,7 +1,6 @@ package proxy import ( - "bytes" "context" "fmt" "ghproxy/config" @@ -31,13 +30,13 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co //err error ) - body := c.Request.Body() + //body := c.Request.Body() - bodyReader := bytes.NewBuffer(body) + //bodyReader := bytes.NewBuffer(body) // 创建请求 if cfg.GitClone.Mode == "cache" { - req, err := gitclient.NewRequest(method, u, bodyReader) + req, err := gitclient.NewRequest(method, u, c.Request.BodyStream()) if err != nil { HandleError(c, fmt.Sprintf("Failed to create request: %v", err)) return @@ -52,7 +51,7 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co return } } else { - req, err := client.NewRequest(method, u, bodyReader) + req, err := client.NewRequest(method, u, c.Request.BodyStream()) if err != nil { HandleError(c, fmt.Sprintf("Failed to create request: %v", err)) return