This commit is contained in:
wjqserver 2025-06-14 06:47:47 +08:00
parent a5bf7686bd
commit d2a0177015
6 changed files with 32 additions and 14 deletions

View file

@ -17,15 +17,16 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co
var (
req *http.Request
resp *http.Response
err error
)
go func() {
<-ctx.Done()
if resp != nil && resp.Body != nil {
resp.Body.Close()
}
if req != nil {
req.Body.Close()
err = resp.Body.Close()
if err != nil {
logError("Failed to close response body: %v", err)
}
}
}()
@ -51,7 +52,7 @@ func GitReq(ctx context.Context, c *app.RequestContext, u string, cfg *config.Co
rb.SetBody(reqBodyReader)
rb.WithContext(ctx)
req, err := rb.Build()
req, err = rb.Build()
if err != nil {
HandleError(c, fmt.Sprintf("Failed to create request: %v", err))
return