mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -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('&');
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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(),
|
||||
|
@@ -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);
|
||||
}
|
||||
// 服务器无返回内容,忽略之
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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 + ">";
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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)));
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user