xkcoding-simple-http

修复 HttpClientImpl timeout 配置失效问题, forked from https://github.com/xkcoding/simple-http, 简单的 http 实现

License

License

GroupId

GroupId

top.dcenter
ArtifactId

ArtifactId

xkcoding-simple-http
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

xkcoding-simple-http
修复 HttpClientImpl timeout 配置失效问题, forked from https://github.com/xkcoding/simple-http, 简单的 http 实现
Project URL

Project URL

https://github.com/xkcoding/simple-http
Source Code Management

Source Code Management

https://github.com/xkcoding/simple-http

Download xkcoding-simple-http

How to add to project

<!-- https://jarcasting.com/artifacts/top.dcenter/xkcoding-simple-http/ -->
<dependency>
    <groupId>top.dcenter</groupId>
    <artifactId>xkcoding-simple-http</artifactId>
    <version>1.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/top.dcenter/xkcoding-simple-http/
implementation 'top.dcenter:xkcoding-simple-http:1.0.4'
// https://jarcasting.com/artifacts/top.dcenter/xkcoding-simple-http/
implementation ("top.dcenter:xkcoding-simple-http:1.0.4")
'top.dcenter:xkcoding-simple-http:jar:1.0.4'
<dependency org="top.dcenter" name="xkcoding-simple-http" rev="1.0.4">
  <artifact name="xkcoding-simple-http" type="jar" />
</dependency>
@Grapes(
@Grab(group='top.dcenter', module='xkcoding-simple-http', version='1.0.4')
)
libraryDependencies += "top.dcenter" % "xkcoding-simple-http" % "1.0.4"
[top.dcenter/xkcoding-simple-http "1.0.4"]

Dependencies

compile (4)

Group / Artifact Type Version
com.squareup.okhttp3 : okhttp Optional jar 4.5.0
org.apache.httpcomponents : httpclient Optional jar 4.5.12
cn.hutool : hutool-http Optional jar 5.2.5
org.projectlombok : lombok-maven-plugin maven-plugin 1.18.12.0

provided (2)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.12
top.dcenter » mock-http-client jar 1.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

Simple-HTTP

Travis-CI MAVEN author JDK LICENSE

简介

抽取一个简单 HTTP 的通用接口,底层实现根据具体引入依赖指定。

<dependency>
  <groupId>com.xkcoding.http</groupId>
  <artifactId>simple-http</artifactId>
  <version>1.0.3</version>
</dependency>

特点

  • 默认会按照下面的优先级自行寻找底层实现,java 11 HttpClient -> OkHttp3 -> apache HttpClient -> hutool-http
  • 也可以自行实现 com.xkcoding.http.support.Http 接口,通过 HttpUtil.setHttp(new MyHttpImpl()) 设置进来
  • 可以配置超时时间及代理
HttpUtil.setConfig(HttpConfig.builder()
			.timeout(Constants.DEFAULT_TIMEOUT)
			.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 10080)))
			.build());
String s = HttpUtil.get("https://www.google.com");
System.out.println("s = " + s);

TODO

Versions

Version
1.0.4
1.0.3