优化github上游链接404的处理

This commit is contained in:
starry
2025-08-01 13:19:47 +08:00
committed by GitHub
parent 83a1211067
commit 4ec36da9b5
2 changed files with 8 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
.idea .idea
.vscode .vscode
.DS_Store .DS_Store
hubproxy* hubproxy*
!hubproxy.service

View File

@@ -122,6 +122,12 @@ func proxyGitHubWithRedirect(c *gin.Context, u string, redirectCount int) {
} }
}() }()
// 如果Github上游404则返回错误信息
if resp.StatusCode == http.StatusNotFound {
c.String(http.StatusForbidden, "无效的GitHub地址")
return
}
// 检查文件大小限制 // 检查文件大小限制
cfg := config.GetConfig() cfg := config.GetConfig()
if contentLength := resp.Header.Get("Content-Length"); contentLength != "" { if contentLength := resp.Header.Get("Content-Length"); contentLength != "" {