mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
25w28b
This commit is contained in:
parent
ab77c5c7da
commit
bed6c486dc
6 changed files with 16 additions and 3 deletions
|
|
@ -56,6 +56,10 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
|
|||
}
|
||||
if err == nil && bodySize > sizelimit {
|
||||
finalURL := resp.Request.URL.String()
|
||||
err := resp.Body.Close()
|
||||
if err != nil {
|
||||
logError("Failed to close response body: %v", err)
|
||||
}
|
||||
c.Redirect(http.StatusMovedPermanently, []byte(finalURL))
|
||||
logWarning("%s %s %s %s %s Final-URL: %s Size-Limit-Exceeded: %d", c.ClientIP(), c.Method(), c.Path(), c.UserAgent(), c.Request.Header.GetProtocol(), finalURL, bodySize)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -243,6 +243,8 @@ func extractParts(rawURL string) (string, string, string, url.Values, error) {
|
|||
return repoOwner, repoName, remainingPath, queryParams, nil
|
||||
}
|
||||
|
||||
var urlPattern = regexp.MustCompile(`https?://[^\s'"]+`)
|
||||
|
||||
// processLinks 处理链接,返回包含处理后数据的 io.Reader
|
||||
func processLinks(input io.Reader, compress string, host string, cfg *config.Config) (readerOut io.Reader, written int64, err error) {
|
||||
pipeReader, pipeWriter := io.Pipe() // 创建 io.Pipe
|
||||
|
|
@ -315,7 +317,6 @@ func processLinks(input io.Reader, compress string, host string, cfg *config.Con
|
|||
}()
|
||||
|
||||
// 使用正则表达式匹配 http 和 https 链接
|
||||
urlPattern := regexp.MustCompile(`https?://[^\s'"]+`)
|
||||
for {
|
||||
line, readErr := bufReader.ReadString('\n')
|
||||
if readErr != nil {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ func setRequestHeaders(c *app.RequestContext, req *http.Request) {
|
|||
})
|
||||
}
|
||||
|
||||
// removeWSHeader removes the "Upgrade" and "Connection" headers from the given
|
||||
// Request, which are added by the client when it wants to upgrade the
|
||||
// connection to a WebSocket connection.
|
||||
func removeWSHeader(req *http.Request) {
|
||||
req.Header.Del("Upgrade")
|
||||
req.Header.Del("Connection")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue