From 399614715ba94115aadd8c513a0fe16b5d70056c Mon Sep 17 00:00:00 2001 From: Looly Date: Wed, 3 Sep 2025 08:57:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`HttpRequest.sendRedirectIfPo?= =?UTF-8?q?ssible`=E6=9C=AA=E5=AF=B9308=E5=81=9A=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82=EF=BC=88issue#4053@Github=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- hutool-http/src/main/java/cn/hutool/http/HttpRequest.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dd9db988..efaa30e79 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.41(2025-08-30) +# 5.8.41(2025-09-03) ### 🐣新特性 * 【core 】 增加`WeakKeyValueConcurrentMap`及其关联类,同时废弃`WeakConcurrentMap`并替换(issue#4039@Github) @@ -16,6 +16,7 @@ * 【core 】 修复`ReflectUtil`中因class和Method关联导致的缓存无法回收问题(issue#4039@Github) * 【db 】 修复`Condition`的`Condition("discount_end_time", "!=", (String) null)`方法生成SQL时,生成SQL不符合预期要求的错误(pr#4042@Github) * 【core 】 修复`IoUtil`的`closeIfPosible`拼写错误,新建一个`closeIfPossible`方法,原方法标记deprecated(issue#4047@Github) +* 【http 】 修复`HttpRequest.sendRedirectIfPossible`未对308做判断问题。(issue#4053@Github) ------------------------------------------------------------------------------------------------------------- # 5.8.40(2025-08-26) diff --git a/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java b/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java index a896fdade..79419bb19 100755 --- a/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpRequest.java @@ -1335,8 +1335,8 @@ public class HttpRequest extends HttpBase { setUrl(redirectUrl); // https://www.rfc-editor.org/rfc/rfc7231#section-6.4.7 // https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Redirections - // 307方法和消息主体都不发生变化。 - if (HttpStatus.HTTP_TEMP_REDIRECT != responseCode) { + // 307、308方法和消息主体都不发生变化。 + if (HttpStatus.HTTP_TEMP_REDIRECT != responseCode && HttpStatus.HTTP_PERMANENT_REDIRECT != responseCode) { // 重定向默认使用GET method(Method.GET); }