This commit is contained in:
Looly
2023-04-12 01:18:11 +08:00
parent bc601ca0ad
commit d2e5155ac5
205 changed files with 500 additions and 492 deletions

View File

@@ -190,7 +190,7 @@ public class HttpUtil {
if (qmIndex > 0) {
// 原URL带参数则对这部分参数单独编码如果选项为进行编码
urlBuilder.append(isEncode ? UrlQueryUtil.encodeQuery(url, charset) : url);
if (false == StrUtil.endWith(url, '&')) {
if (! StrUtil.endWith(url, '&')) {
// 已经带参数的情况下追加参数
urlBuilder.append('&');
}

View File

@@ -130,7 +130,7 @@ public class MultipartOutputStream extends OutputStream {
* @throws IORuntimeException IO异常
*/
public void finish() throws IORuntimeException {
if (false == isFinish) {
if (! isFinish) {
write(StrUtil.format("--{}--\r\n", boundary));
this.isFinish = true;
}

View File

@@ -227,7 +227,7 @@ public class ResponseBody implements HttpBody, Closeable {
* @since 5.4.1
*/
private File getTargetFile(final File targetFileOrDir, final String customParamName) {
if (false == targetFileOrDir.isDirectory()) {
if (! targetFileOrDir.isDirectory()) {
// 非目录直接返回
return targetFileOrDir;
}

View File

@@ -69,7 +69,7 @@ public class HttpUrlConnectionUtil {
// 首先去除修饰符,否则设置值失败
ModifierUtil.removeFinalModify(methodsField);
final Object staticFieldValue = FieldUtil.getStaticFieldValue(methodsField);
if (false == ArrayUtil.equals(METHODS, staticFieldValue)) {
if (! ArrayUtil.equals(METHODS, staticFieldValue)) {
// 去除final修饰
FieldUtil.setStaticFieldValue(methodsField, METHODS);
}
@@ -86,7 +86,7 @@ public class HttpUrlConnectionUtil {
*/
public static HttpURLConnection openHttp(final URL url, final Proxy proxy) throws IORuntimeException {
final URLConnection conn = openConnection(url, proxy);
if (false == conn instanceof HttpURLConnection) {
if (! conn instanceof HttpURLConnection) {
// 防止其它协议造成的转换异常
throw new HttpException("'{}' of URL [{}] is not a http connection, make sure URL is format for http.",
conn.getClass().getName(), url);

View File

@@ -201,10 +201,10 @@ public class JdkClientEngine implements ClientEngine {
*/
private static UrlBuilder getLocationUrl(final UrlBuilder parentUrl, String location) {
final UrlBuilder redirectUrl;
if (false == HttpUtil.isHttp(location) && false == HttpUtil.isHttps(location)) {
if (! HttpUtil.isHttp(location) && ! HttpUtil.isHttps(location)) {
// issue#I5TPSY
// location可能为相对路径
if (false == location.startsWith("/")) {
if (! location.startsWith("/")) {
location = StrUtil.addSuffixIfNot(parentUrl.getPathStr(), "/") + location;
}
redirectUrl = UrlBuilder.of(parentUrl.getScheme(), parentUrl.getHost(), parentUrl.getPort(),

View File

@@ -94,7 +94,7 @@ public class JdkHttpInputStream extends InputStream {
try {
this.in = (response.status < HttpStatus.HTTP_BAD_REQUEST) ? response.httpConnection.getInputStream() : response.httpConnection.getErrorStream();
} catch (final IOException e) {
if (false == (e instanceof FileNotFoundException)) {
if (! (e instanceof FileNotFoundException)) {
throw new HttpException(e);
}
// 服务器无返回内容,忽略之

View File

@@ -252,7 +252,7 @@ public class JdkHttpResponse implements Response, Closeable {
try {
this.status = httpConnection.getCode();
} catch (final IOException e) {
if (false == (e instanceof FileNotFoundException)) {
if (! (e instanceof FileNotFoundException)) {
throw new HttpException(e);
}
// 服务器无返回内容,忽略之
@@ -270,7 +270,7 @@ public class JdkHttpResponse implements Response, Closeable {
GlobalCookieManager.store(httpConnection, this.headers);
// 获取响应内容流
if (false == isIgnoreBody) {
if (! isIgnoreBody) {
this.body = new ResponseBody(this, new JdkHttpInputStream(this), isAsync, this.ignoreEOFError);
}
}

View File

@@ -376,7 +376,7 @@ public final class HTMLFilter {
if (m.find()) {
final String name = m.group(1).toLowerCase();
if (allowed(name)) {
if (false == inArray(name, vSelfClosingTags)) {
if (! inArray(name, vSelfClosingTags)) {
if (vTagCounts.containsKey(name)) {
vTagCounts.put(name, vTagCounts.get(name) - 1);
return "</" + name + ">";

View File

@@ -289,7 +289,7 @@ public class HtmlUtil {
}
// ignore
}
if (null != charsetInContent && false == charset.equals(charsetInContent)) {
if (null != charsetInContent && ! charset.equals(charsetInContent)) {
content = new String(contentBytes, charsetInContent);
}
}

View File

@@ -256,7 +256,7 @@ public class HttpServerRequest extends HttpServerBase {
* @return 是否为Multipart类型表单此类型表单用于文件上传
*/
public boolean isMultipart() {
if (false == isPostMethod()) {
if (! isPostMethod()) {
return false;
}
@@ -406,7 +406,7 @@ public class HttpServerRequest extends HttpServerBase {
String ip;
for (final String header : headerNames) {
ip = getHeader(header);
if (false == NetUtil.isUnknown(ip)) {
if (! NetUtil.isUnknown(ip)) {
return NetUtil.getMultistageReverseProxyIp(ip);
}
}

View File

@@ -202,7 +202,7 @@ public class HttpServerResponse extends HttpServerBase {
*/
public HttpServerResponse setContentType(String contentType) {
if (null != contentType && null != this.charset) {
if (false == contentType.contains(";charset=")) {
if (! contentType.contains(";charset=")) {
contentType = ContentType.build(contentType, this.charset);
}
}
@@ -249,7 +249,7 @@ public class HttpServerResponse extends HttpServerBase {
* @return 响应数据流
*/
public OutputStream getOut() {
if (false == this.isSendCode) {
if (! this.isSendCode) {
sendOk();
}
return this.httpExchange.getResponseBody();
@@ -355,7 +355,7 @@ public class HttpServerResponse extends HttpServerBase {
* @return this
*/
public HttpServerResponse write(final InputStream in, final int length) {
if (false == isSendCode) {
if (! isSendCode) {
sendOk(Math.max(0, length));
}
OutputStream out = null;
@@ -433,7 +433,7 @@ public class HttpServerResponse extends HttpServerBase {
public HttpServerResponse write(final InputStream in, final int length, final String contentType, final String fileName) {
final Charset charset = ObjUtil.defaultIfNull(this.charset, DEFAULT_CHARSET);
if (false == contentType.startsWith("text/")) {
if (! contentType.startsWith("text/")) {
// 非文本类型数据直接走下载
setHeader(Header.CONTENT_DISPOSITION, StrUtil.format("attachment;filename={}", URLEncoder.encodeAll(fileName, charset)));
}

View File

@@ -244,7 +244,7 @@ public class JakartaServletUtil {
String ip;
for (final String header : headerNames) {
ip = request.getHeader(header);
if (false == NetUtil.isUnknown(ip)) {
if (! NetUtil.isUnknown(ip)) {
return NetUtil.getMultistageReverseProxyIp(ip);
}
}
@@ -426,7 +426,7 @@ public class JakartaServletUtil {
* @return 是否为Multipart类型表单此类型表单用于文件上传
*/
public static boolean isMultipart(final HttpServletRequest request) {
if (false == isPostMethod(request)) {
if (! isPostMethod(request)) {
return false;
}

View File

@@ -243,7 +243,7 @@ public class ServletUtil {
String ip;
for (final String header : headerNames) {
ip = request.getHeader(header);
if (false == NetUtil.isUnknown(ip)) {
if (! NetUtil.isUnknown(ip)) {
return NetUtil.getMultistageReverseProxyIp(ip);
}
}
@@ -437,7 +437,7 @@ public class ServletUtil {
* @return 是否为Multipart类型表单此类型表单用于文件上传
*/
public static boolean isMultipart(final HttpServletRequest request) {
if (false == isPostMethod(request)) {
if (! isPostMethod(request)) {
return false;
}