mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
fix code
This commit is contained in:
@@ -53,7 +53,7 @@ public class HttpDownloader {
|
||||
* @param url 请求地址
|
||||
* @return 下载器
|
||||
*/
|
||||
public static HttpDownloader of(ClientEngine engine, String url) {
|
||||
public static HttpDownloader of(final ClientEngine engine, final String url) {
|
||||
return of(url).setEngine(engine).setCloseEngine(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ public class HttpClient4Engine extends AbstractClientEngine {
|
||||
);
|
||||
|
||||
// 连接池配置
|
||||
if (config instanceof ApacheHttpClientConfig apacheHttpClientConfig) {
|
||||
if (config instanceof final ApacheHttpClientConfig apacheHttpClientConfig) {
|
||||
final int maxTotal = apacheHttpClientConfig.getMaxTotal();
|
||||
if (maxTotal > 0) {
|
||||
manager.setMaxTotal(maxTotal);
|
||||
|
||||
@@ -189,7 +189,7 @@ public class HttpClient5Engine extends AbstractClientEngine {
|
||||
connectionManagerBuilder.setDefaultConnectionConfig(connectionConfigBuilder.build());
|
||||
|
||||
// 连接池配置
|
||||
if (config instanceof ApacheHttpClientConfig apacheHttpClientConfig) {
|
||||
if (config instanceof final ApacheHttpClientConfig apacheHttpClientConfig) {
|
||||
final int maxTotal = apacheHttpClientConfig.getMaxTotal();
|
||||
if (maxTotal > 0) {
|
||||
connectionManagerBuilder.setMaxConnTotal(maxTotal);
|
||||
|
||||
@@ -219,7 +219,7 @@ public class JdkHttpConnection implements HeaderOperation<JdkHttpConnection>, Cl
|
||||
public JdkHttpConnection setSSLInfo(final SSLInfo sslInfo) throws HttpException {
|
||||
final HttpURLConnection conn = this.conn;
|
||||
|
||||
if (conn instanceof HttpsURLConnection httpsConn) {
|
||||
if (conn instanceof final HttpsURLConnection httpsConn) {
|
||||
// Https请求
|
||||
// 验证域
|
||||
Opt.ofNullable(sslInfo.getHostnameVerifier()).ifPresent(httpsConn::setHostnameVerifier);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class JettyHandler extends Handler.Abstract {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(Request request, Response response, Callback callback) {
|
||||
public boolean handle(final Request request, final Response response, final Callback callback) {
|
||||
handler.handle(new JettyRequest(request), new JettyResponse(response));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class JettyRequest implements ServerRequest {
|
||||
*
|
||||
* @param request Jetty请求对象
|
||||
*/
|
||||
public JettyRequest(Request request) {
|
||||
public JettyRequest(final Request request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class JettyRequest implements ServerRequest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
public String getHeader(final String name) {
|
||||
return request.getHeaders().get(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,18 +38,18 @@ public class JettyResponse implements ServerResponse {
|
||||
*
|
||||
* @param response Jetty响应对象
|
||||
*/
|
||||
public JettyResponse(Response response) {
|
||||
public JettyResponse(final Response response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JettyResponse setStatus(int statusCode) {
|
||||
public JettyResponse setStatus(final int statusCode) {
|
||||
response.setStatus(statusCode);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JettyResponse setCharset(Charset charset) {
|
||||
public JettyResponse setCharset(final Charset charset) {
|
||||
this.charset = charset;
|
||||
return this;
|
||||
}
|
||||
@@ -60,13 +60,13 @@ public class JettyResponse implements ServerResponse {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JettyResponse addHeader(String header, String value) {
|
||||
public JettyResponse addHeader(final String header, final String value) {
|
||||
response.getHeaders().add(header, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JettyResponse setHeader(String header, String value) {
|
||||
public JettyResponse setHeader(final String header, final String value) {
|
||||
response.getHeaders().put(header, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -81,10 +81,10 @@ public class SmartHttpServerEngine extends AbstractServerEngine {
|
||||
if(null != sslContext){
|
||||
try {
|
||||
// 使用反射创建SslPlugin
|
||||
Class<?> sslPluginClass = Class.forName("org.smartboot.socket.extension.plugins.SslPlugin");
|
||||
Object sslPlugin = sslPluginClass.getConstructor(Supplier.class).newInstance((Supplier<SSLContext>) () -> sslContext);
|
||||
final Class<?> sslPluginClass = Class.forName("org.smartboot.socket.extension.plugins.SslPlugin");
|
||||
final Object sslPlugin = sslPluginClass.getConstructor(Supplier.class).newInstance((Supplier<SSLContext>) () -> sslContext);
|
||||
// 使用反射调用addPlugin方法
|
||||
Method addPlugin = configuration.getClass().getMethod("addPlugin", Object.class);
|
||||
final Method addPlugin = configuration.getClass().getMethod("addPlugin", Object.class);
|
||||
addPlugin.invoke(configuration, sslPlugin);
|
||||
} catch (final Exception e) {
|
||||
throw new HttpException(e);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Issue3240Test {
|
||||
@Test
|
||||
@Disabled
|
||||
void okHttpTest() {
|
||||
String url = "https://gh.yubue.cn/https://github.com/espressif/arduino-esp32/releases/download/2.0.11/package_esp32_dev_index.json";
|
||||
final String url = "https://gh.yubue.cn/https://github.com/espressif/arduino-esp32/releases/download/2.0.11/package_esp32_dev_index.json";
|
||||
final ClientEngine engine = HttpUtil.createClient("okhttp");
|
||||
final Response send = engine.send(Request.of(url).method(Method.GET));
|
||||
Console.log(send.body().getString());
|
||||
@@ -36,7 +36,7 @@ public class Issue3240Test {
|
||||
@Test
|
||||
@Disabled
|
||||
void httpClient4Test() {
|
||||
String url = "https://gh.yubue.cn/https://github.com/espressif/arduino-esp32/releases/download/2.0.11/package_esp32_dev_index.json";
|
||||
final String url = "https://gh.yubue.cn/https://github.com/espressif/arduino-esp32/releases/download/2.0.11/package_esp32_dev_index.json";
|
||||
final ClientEngine engine = HttpUtil.createClient("okhttp");
|
||||
final Response send = engine.send(Request.of(url).method(Method.GET));
|
||||
Console.log(send.body().getString());
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
public class Issue3765Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(final String[] args) {
|
||||
HttpUtil.createServer(8888)
|
||||
.setRoot("d:/test/www")
|
||||
.start();
|
||||
|
||||
@@ -27,7 +27,7 @@ public class IssueIB1QHQTest {
|
||||
@Disabled
|
||||
void requestByOkHttpTest() {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
String response = ClientEngineFactory.createEngine("OkHttp")
|
||||
final String response = ClientEngineFactory.createEngine("OkHttp")
|
||||
.send(Request
|
||||
.of("https://hutool.cn")
|
||||
.method(Method.POST)
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* form-data: file: file-data
|
||||
*/
|
||||
public class IssueI6Q30XTest {
|
||||
public static void main(String[] args) {
|
||||
public static void main(final String[] args) {
|
||||
final SimpleServer server = HttpUtil.createServer(8888);
|
||||
server.addAction("/file", (request, response) -> {
|
||||
Console.log(((SunServerRequest)request).getHeaders().entrySet());
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.net.ssl.SSLContext;
|
||||
import java.security.KeyStore;
|
||||
|
||||
public class SunServerTest {
|
||||
public static void main(String[] args) {
|
||||
public static void main(final String[] args) {
|
||||
final char[] pwd = "123456".toCharArray();
|
||||
final KeyStore keyStore = KeyStoreUtil.readJKSKeyStore(FileUtil.file("d:/test/keystore.jks"), pwd);
|
||||
// 初始化SSLContext
|
||||
|
||||
Reference in New Issue
Block a user