This commit is contained in:
wjqserver 2025-05-14 17:55:37 +08:00
parent 47c03763a7
commit ce814875e1
6 changed files with 46 additions and 8 deletions

View file

@ -13,6 +13,22 @@ import (
)
func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Config, mode string) {
var (
req *http.Request
resp *http.Response
)
go func() {
<-ctx.Done()
if resp != nil && resp.Body != nil {
resp.Body.Close()
}
if req != nil {
req.Body.Close()
}
}()
method := string(c.Request.Method())
reqBodyReader := bytes.NewBuffer(c.Request.Body())
@ -29,10 +45,6 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co
u = cfg.GitClone.SmartGitAddr + userPath + repoPath + remainingPath + "?" + queryParams.Encode()
}
var (
resp *http.Response
)
if cfg.GitClone.Mode == "cache" {
rb := gitclient.NewRequestBuilder(method, u)
rb.NoDefaultHeaders()