From bf21bd197ae12c0711647345c579fef37775068a Mon Sep 17 00:00:00 2001 From: wjqserver <114663932+WJQSERVER@users.noreply.github.com> Date: Fri, 11 Apr 2025 07:29:03 +0800 Subject: [PATCH] 25w28t-2 --- CHANGELOG.md | 5 +++++ DEV-VERSION | 2 +- proxy/chunkreq.go | 12 +++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc0931e..74a19fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # 更新日志 +25w28t-2 - 2025-04-11 +--- +- TEST: 测试验证版本 +- CHANGE: 为老旧的油猴xhr提供兼容性支持, break RFC 2616, RFC 9112 + 25w28t-1 - 2025-04-11 --- - TEST: 测试验证版本 diff --git a/DEV-VERSION b/DEV-VERSION index 42eb3c3..c774704 100644 --- a/DEV-VERSION +++ b/DEV-VERSION @@ -1 +1 @@ -25w28t-1 \ No newline at end of file +25w28t-2 \ No newline at end of file diff --git a/proxy/chunkreq.go b/proxy/chunkreq.go index 0212e0d..dffb6ef 100644 --- a/proxy/chunkreq.go +++ b/proxy/chunkreq.go @@ -74,13 +74,15 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c return } + var bodySize int contentLength = resp.Header.Get("Content-Length") if contentLength != "" { - size, err := strconv.Atoi(contentLength) - if err == nil && size > sizelimit { + var err error + bodySize, err = strconv.Atoi(contentLength) + if err == nil && bodySize > sizelimit { finalURL := resp.Request.URL.String() 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 } } @@ -132,6 +134,10 @@ func ChunkedProxyRequest(ctx context.Context, c *app.RequestContext, u string, c return } } else { + if contentLength != "" { + c.SetBodyStream(resp.Body, bodySize) + return + } c.SetBodyStream(resp.Body, -1) }