Skip to content

Commit a3e649d

Browse files
committed
新增 solon-net-httputils17 插件
1 parent 09591da commit a3e649d

64 files changed

Lines changed: 5553 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

UPDATE_LOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
### v3.8.1
3+
4+
* 新增 solon-net-httputils17 插件
5+
26
### v3.8.0
37

48
* 添加 `solon-server-tomcat-jakarta` ssl、vthread 支持

__release/solon-java17-bundle1/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
<module>../../solon-java17-projects/solon-logging/solon-logging-logback-jakarta</module>
2525

26+
<module>../../solon-java17-projects/solon-net/solon-net-httputils17</module>
27+
2628
<module>../../solon-java17-projects/solon-serialization/solon-serialization-jackson3</module>
2729
<module>../../solon-java17-projects/solon-serialization/solon-serialization-jackson3-xml</module>
2830

solon-java17-parent/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<jakarta.websocket2.version>2.2.0</jakarta.websocket2.version>
2727

2828
<jackson3.version>3.0.2</jackson3.version>
29+
<okhttp5.version>5.3.2</okhttp5.version>
2930

3031
<cxf.version>4.1.2</cxf.version>
3132

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
3+
服务调用示例:
4+
5+
```java
6+
public class App {
7+
public static void maing(String[] args) {
8+
Solon.start(App.class, args);
9+
10+
//通过服务名进行http请求
11+
HttpUtils.http("HelloService","/hello").get();
12+
}
13+
}
14+
```
15+
16+
17+
18+
19+
预热示例:
20+
21+
```java
22+
public class App {
23+
public static void maing(String[] args) {
24+
Solon.start(App.class, args);
25+
26+
//用http请求自己进行预热
27+
PreheatUtils.preheat("/healthz");
28+
29+
//用bean预热
30+
HelloService service = Aop.get(HelloService.class);
31+
service.hello();
32+
}
33+
}
34+
```
35+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.noear</groupId>
9+
<artifactId>solon-java17-parent</artifactId>
10+
<version>3.8.1-SNAPSHOT</version>
11+
<relativePath>../../../solon-java17-parent/pom.xml</relativePath>
12+
</parent>
13+
14+
<artifactId>solon-net-httputils17</artifactId>
15+
<name>${project.artifactId}</name>
16+
<packaging>jar</packaging>
17+
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.noear</groupId>
22+
<artifactId>solon</artifactId>
23+
</dependency>
24+
25+
<dependency>
26+
<groupId>org.noear</groupId>
27+
<artifactId>solon-serialization</artifactId>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>org.noear</groupId>
32+
<artifactId>solon-rx</artifactId>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>org.slf4j</groupId>
37+
<artifactId>slf4j-api</artifactId>
38+
</dependency>
39+
40+
<dependency>
41+
<groupId>com.squareup.okhttp3</groupId>
42+
<artifactId>okhttp-jvm</artifactId>
43+
<version>${okhttp5.version}</version>
44+
<optional>true</optional>
45+
</dependency>
46+
47+
48+
<dependency>
49+
<groupId>com.github.mrmike</groupId>
50+
<artifactId>ok2curl</artifactId>
51+
<version>0.8.0</version>
52+
<optional>true</optional>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>org.junit.jupiter</groupId>
57+
<artifactId>junit-jupiter</artifactId>
58+
<version>${junit5.version}</version>
59+
<scope>test</scope>
60+
</dependency>
61+
</dependencies>
62+
63+
</project>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright 2017-2025 noear.org and authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.noear.solon.net.http;
17+
18+
import org.noear.solon.net.http.impl.HttpUtilsFactoryDefault;
19+
20+
import java.util.*;
21+
22+
/**
23+
* Http 配置类
24+
*
25+
* @author noear
26+
* @since 2.9
27+
*/
28+
public class HttpConfiguration {
29+
private static Set<HttpExtension> extensions = new LinkedHashSet<>();
30+
private static HttpUtilsFactory factory = new HttpUtilsFactoryDefault();
31+
32+
/**
33+
* 添加扩展
34+
*/
35+
public static void addExtension(HttpExtension extension) {
36+
extensions.add(extension);
37+
}
38+
39+
/**
40+
* 移除扩展
41+
*/
42+
public static void removeExtension(HttpExtension extension) {
43+
extensions.remove(extension);
44+
}
45+
46+
/**
47+
* 获取所有扩展
48+
*/
49+
public static Collection<HttpExtension> getExtensions() {
50+
return extensions;
51+
}
52+
53+
/**
54+
* 获取工厂
55+
*/
56+
public static HttpUtilsFactory getFactory() {
57+
return factory;
58+
}
59+
60+
/**
61+
* 设置工厂
62+
*/
63+
public static void setFactory(HttpUtilsFactory factory) {
64+
HttpConfiguration.factory = factory;
65+
}
66+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2017-2025 noear.org and authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.noear.solon.net.http;
17+
18+
import org.noear.solon.exception.SolonException;
19+
20+
/**
21+
* Http 异常
22+
*
23+
* @author noear
24+
* @since 3.1
25+
*/
26+
public class HttpException extends SolonException {
27+
public HttpException(String message) {
28+
super(message);
29+
}
30+
31+
public HttpException(String message, Throwable cause) {
32+
super(message, cause);
33+
}
34+
35+
public HttpException(Throwable cause) {
36+
super(cause);
37+
}
38+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2017-2025 noear.org and authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.noear.solon.net.http;
17+
18+
/**
19+
* Http 扩展
20+
*
21+
* @author noear
22+
* @since 2.9
23+
*/
24+
public interface HttpExtension {
25+
/**
26+
* 初始化
27+
*/
28+
default void onInit(HttpUtils httpUtils, String url) {
29+
30+
}
31+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2017-2025 noear.org and authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.noear.solon.net.http;
17+
18+
import java.util.Collection;
19+
20+
/**
21+
* Http 扩展管理
22+
*
23+
* @author noear
24+
* @since 2.9
25+
* @deprecated 3.0
26+
*/
27+
@Deprecated
28+
public class HttpExtensionManager {
29+
/**
30+
* 添加扩展
31+
*/
32+
public static void add(HttpExtension extension) {
33+
HttpConfiguration.addExtension(extension);
34+
}
35+
36+
/**
37+
* 移除扩展
38+
*/
39+
public static void remove(HttpExtension extension) {
40+
HttpConfiguration.removeExtension(extension);
41+
}
42+
43+
/**
44+
* 获取所有扩展
45+
*/
46+
public static Collection<HttpExtension> getExtensions() {
47+
return HttpConfiguration.getExtensions();
48+
}
49+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2017-2025 noear.org and authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.noear.solon.net.http;
17+
18+
import java.io.Serializable;
19+
20+
/**
21+
* Http 代理
22+
*
23+
* @author noear
24+
* @since 3.1
25+
*/
26+
public class HttpProxy implements Serializable {
27+
private String host;
28+
private int port;
29+
30+
public static HttpProxy of(String host, int port) {
31+
HttpProxy tmp = new HttpProxy();
32+
tmp.host = host;
33+
tmp.port = port;
34+
return tmp;
35+
}
36+
37+
public String getHost() {
38+
return host;
39+
}
40+
41+
public int getPort() {
42+
return port;
43+
}
44+
45+
public void setHost(String host) {
46+
this.host = host;
47+
}
48+
49+
public void setPort(int port) {
50+
this.port = port;
51+
}
52+
}

0 commit comments

Comments
 (0)