Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xkcoding/simple-http
抽取一个简单 HTTP 的通用接口,底层实现根据具体引入依赖指定。
https://github.com/xkcoding/simple-http
http httpclient hutool-http java okhttp3 xkcoding
Last synced: 13 days ago
JSON representation
抽取一个简单 HTTP 的通用接口,底层实现根据具体引入依赖指定。
- Host: GitHub
- URL: https://github.com/xkcoding/simple-http
- Owner: xkcoding
- License: lgpl-3.0
- Created: 2019-12-24T10:37:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-09T03:42:35.000Z (almost 2 years ago)
- Last Synced: 2024-10-22T15:25:19.785Z (23 days ago)
- Topics: http, httpclient, hutool-http, java, okhttp3, xkcoding
- Language: Java
- Homepage:
- Size: 108 KB
- Stars: 52
- Watchers: 4
- Forks: 21
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Simple-HTTP
## 简介
> 抽取一个简单 HTTP 的通用接口,底层实现根据具体引入依赖指定。
```xml
com.xkcoding.http
simple-http
1.0.5```
## 特点
- 默认会按照下面的优先级自行寻找底层实现,`java 11 HttpClient -> OkHttp3 -> apache HttpClient -> hutool-http`
- 也可以自行实现 `com.xkcoding.http.support.Http` 接口,通过 `HttpUtil.setHttp(new MyHttpImpl())` 设置进来
- 可以配置超时时间及代理
```java
HttpUtil.setConfig(HttpConfig.builder()
.timeout(Constants.DEFAULT_TIMEOUT)
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
.build());
SimpleHttpResponse response = HttpUtil.get("https://www.google.com");
System.out.println("code = " + response.getCode());
System.out.println("body = " + response.getBody());
```## TODO
- [x] ~~集成 JDK11 的 HTTPClient~~(感谢[@春哥](https://github.com/ChunMengLu)的 [PR#1](https://github.com/xkcoding/simple-http/pull/1))
- [x] ~~支持代理~~(感谢[@亚东](https://github.com/zhangyd-c)的 [PR#7](https://github.com/xkcoding/simple-http/pull/7))
- [x] ~~Response 封装~~(感谢[@小海](https://github.com/Mvbbb)的 [PR#11](https://github.com/xkcoding/simple-http/pull/11))