This commit is contained in:
wjqserver 2025-04-11 07:29:03 +08:00
parent 8af107c584
commit bf21bd197a
3 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,10 @@
# 更新日志 # 更新日志
25w28t-2 - 2025-04-11
---
- TEST: 测试验证版本
- CHANGE: 为老旧的油猴xhr提供兼容性支持, break RFC 2616, RFC 9112
25w28t-1 - 2025-04-11 25w28t-1 - 2025-04-11
--- ---
- TEST: 测试验证版本 - TEST: 测试验证版本

View file

@ -1 +1 @@
25w28t-1 25w28t-2

View file

@ -74,13 +74,15 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
return return
} }
var bodySize int
contentLength = resp.Header.Get("Content-Length") contentLength = resp.Header.Get("Content-Length")
if contentLength != "" { if contentLength != "" {
size, err := strconv.Atoi(contentLength) var err error
if err == nil && size > sizelimit { bodySize, err = strconv.Atoi(contentLength)
if err == nil && bodySize > sizelimit {
finalURL := resp.Request.URL.String() finalURL := resp.Request.URL.String()
c.Redirect(http.StatusMovedPermanently, []byte(finalURL)) 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, size) 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 return
} }
} }
@ -132,6 +134,10 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c
return return
} }
} else { } else {
if contentLength != "" {
c.SetBodyStream(resp.Body, bodySize)
return
}
c.SetBodyStream(resp.Body, -1) c.SetBodyStream(resp.Body, -1)
} }