From 47eb0e1b499fa9eecdd40b05b9a8166fc3ac2017 Mon Sep 17 00:00:00 2001 From: NewName Date: Tue, 20 May 2025 21:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhttp=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ghproxy/search.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ghproxy/search.go b/ghproxy/search.go index 8e7349a..d5f2478 100644 --- a/ghproxy/search.go +++ b/ghproxy/search.go @@ -267,6 +267,16 @@ func searchDockerHub(ctx context.Context, query string, page, pageSize int) (*Se fullURL = fullURL + "?" + params.Encode() + // 创建请求 + req, err := http.NewRequestWithContext(ctx, "GET", fullURL, nil) + if err != nil { + return nil, fmt.Errorf("创建请求失败: %v", err) + } + + // 设置请求头 + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36") + // 使用全局HTTP客户端 client := defaultHTTPClient