格式化

This commit is contained in:
redkale
2024-09-14 23:21:23 +08:00
parent c4a02e05e1
commit cc5a3106aa
2 changed files with 10 additions and 19 deletions

View File

@@ -781,7 +781,7 @@ public class HttpRequest extends Request<HttpContext> {
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<HttpContext> {
.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<HttpContext> {
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;
}

View File

@@ -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);
}
/**