Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

xkcoding/simple-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

57 Commits

Repository files navigation

Travis-CI MAVEN author JDK LICENSE

简介

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

<dependency>
 <groupId>com.xkcoding.http</groupId>
 <artifactId>simple-http</artifactId>
 <version>1.0.5</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());
SimpleHttpResponse response = HttpUtil.get("https://www.google.com");
System.out.println("code = " + response.getCode());
System.out.println("body = " + response.getBody());

TODO

  • (削除) 集成 JDK11 的 HTTPClient (削除ここまで)(感谢@春哥PR#1)
  • (削除) 支持代理 (削除ここまで)(感谢@亚东PR#7)
  • (削除) Response 封装 (削除ここまで)(感谢@小海PR#11)

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages

AltStyle によって変換されたページ (->オリジナル) /