From cc5a3106aa035a81fa00e354945aef92f75c3661 Mon Sep 17 00:00:00 2001 From: redkale Date: Sat, 14 Sep 2024 23:21:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/redkale/net/http/HttpRequest.java | 9 ++++----- src/main/java/org/redkale/util/ByteArray.java | 20 ++++++------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/redkale/net/http/HttpRequest.java b/src/main/java/org/redkale/net/http/HttpRequest.java index ae5a9f25d..b07248b44 100644 --- a/src/main/java/org/redkale/net/http/HttpRequest.java +++ b/src/main/java/org/redkale/net/http/HttpRequest.java @@ -781,7 +781,7 @@ public class HttpRequest extends Request { if (qst > 0) { // 带?参数 this.requestPath = decodeable ? toDecodeString(bytes, 0, qst, charset) - : context.loadUriPath(bytes, qst, latin1, charset); // bytes.toString(latin1, 0, qst, charset); + : context.loadUriPath(bytes, qst, latin1, charset); int qlen = size - qst - 1; this.queryBytes = bytes.getBytes(qst + 1, qlen); this.lastPathString = null; @@ -793,7 +793,7 @@ public class HttpRequest extends Request { .getLogger() .log(Level.WARNING, "HttpRequest.addParameter error: " + bytes.toString(), e); } - } else { + } else { // 没有带?参数 if (decodeable) { // 需要转义 this.requestPath = toDecodeString(bytes, 0, bytes.length(), charset); this.lastPathString = null; @@ -803,13 +803,12 @@ public class HttpRequest extends Request { if (lastURIBytes != null && lastURIBytes.length == size && bytes.deepEquals(lastURIBytes)) { this.requestPath = this.lastPathString; } else { - this.requestPath = - context.loadUriPath(bytes, latin1, charset); // bytes.toString(latin1, charset); + this.requestPath = context.loadUriPath(bytes, latin1, charset); this.lastPathString = this.requestPath; this.lastPathBytes = bytes.getBytes(); } } else { - this.requestPath = context.loadUriPath(bytes, latin1, charset); // bytes.toString(latin1, charset); + this.requestPath = context.loadUriPath(bytes, latin1, charset); this.lastPathString = null; this.lastPathBytes = null; } diff --git a/src/main/java/org/redkale/util/ByteArray.java b/src/main/java/org/redkale/util/ByteArray.java index 8b3788dab..3771f36f9 100644 --- a/src/main/java/org/redkale/util/ByteArray.java +++ b/src/main/java/org/redkale/util/ByteArray.java @@ -146,10 +146,7 @@ public final class ByteArray implements ByteTuple { * @return 是否相同 */ public boolean deepEquals(final byte[] bytes) { - if (bytes == null) { - return false; - } - return deepEquals(bytes, 0, bytes.length); + return bytes != null && deepEquals(bytes, 0, bytes.length); } /** @@ -167,11 +164,12 @@ public final class ByteArray implements ByteTuple { if (count != length) { return false; } - byte[] ba = content; + byte[] bs1 = content; + byte[] bs2 = bytes; int len = count; int off = offset; for (int i = 0; i < len; i++) { - if (ba[i] != bytes[off + i]) { + if (bs1[i] != bs2[off + i]) { return false; } } @@ -185,10 +183,7 @@ public final class ByteArray implements ByteTuple { * @return 是否相同 */ public boolean deepEquals(final ByteTuple tuple) { - if (tuple == null) { - return false; - } - return deepEquals(tuple.content(), 0, tuple.length()); + return tuple != null && deepEquals(tuple.content(), 0, tuple.length()); } /** @@ -198,10 +193,7 @@ public final class ByteArray implements ByteTuple { * @return 是否相同 */ public boolean deepEquals(final ByteArray array) { - if (array == null) { - return false; - } - return deepEquals(array.content, 0, array.count); + return array != null && deepEquals(array.content, 0, array.count); } /**