From cbca05ef41cc84c3874c65554b41c646617fad37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=A5=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=BE=D0=B2?= Date: Sat, 4 Oct 2025 00:46:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20time=20=D0=B4=D0=BB=D1=8F=20retry=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/builtins/http.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/builtins/http.go b/internal/builtins/http.go index 4e9176d..7b07cd1 100644 --- a/internal/builtins/http.go +++ b/internal/builtins/http.go @@ -25,6 +25,7 @@ import ( "io" "net/http" "strings" + "time" "go.elara.ws/logger/log" "gitea.plemya-x.ru/Plemya-x/ALR-updater/internal/config" @@ -86,8 +87,9 @@ func makeRequestWithConfig(name, method string, args starlark.Tuple, kwargs []st redirect = true headers = &starlarkHeaders{} body = newBodyReader() + timeout int64 = 30 // Таймаут по умолчанию 30 секунд ) - err := starlark.UnpackArgs(name, args, kwargs, "url", &url, "redirect??", &redirect, "headers??", headers, "body??", body) + err := starlark.UnpackArgs(name, args, kwargs, "url", &url, "redirect??", &redirect, "headers??", headers, "body??", body, "timeout??", &timeout) if err != nil { return nil, err } @@ -107,12 +109,12 @@ func makeRequestWithConfig(name, method string, args starlark.Tuple, kwargs []st req.Header.Set("Authorization", "token "+cfg.GitHub.Token) } - client := http.DefaultClient + client := &http.Client{ + Timeout: time.Duration(timeout) * time.Second, + } if !redirect { - client = &http.Client{ - CheckRedirect: func(req *http.Request, via []*http.Request) error { - return http.ErrUseLastResponse - }, + client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse } }