优化github上游链接404的处理
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
.DS_Store
|
.DS_Store
|
||||||
hubproxy*
|
hubproxy*
|
||||||
|
!hubproxy.service
|
||||||
@@ -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 != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user