Xkcoding Simple Http Save

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

Project README

Simple-HTTP

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

Open Source Agenda is not affiliated with "Xkcoding Simple Http" Project. README Source: xkcoding/simple-http
Stars
50
Open Issues
5
Last Commit
1 year ago

Open Source Agenda Badge

Open Source Agenda Rating