MCPcopy Create free account
hub / github.com/SeanDragon/protools / ToolHttp

Class ToolHttp

http/src/main/java/pro/tools/http/jdk/ToolHttp.java:35–208  ·  view source on GitHub ↗

Created on 17/4/6 22:06 星期四. @author SeanDragon

Source from the content-addressed store, hash-verified

33 * @author SeanDragon
34 */
35public final class ToolHttp {
36 private static final Logger log = LoggerFactory.getLogger(ToolHttp.class);
37 private static HttpBuilder builder = new HttpBuilder();
38
39 private ToolHttp() {
40 throw new UnsupportedOperationException("我是工具类,别初始化我。。。");
41 }
42
43 public static HttpReceive sendGet(String url) {
44 HttpSend send = new HttpSend(url)
45 .setMethod(HttpMethod.GET);
46 return sendHttp(send);
47 }
48
49 public static HttpReceive sendPost(String url) {
50 HttpSend send = new HttpSend(url)
51 .setMethod(HttpMethod.POST);
52 return sendHttp(send);
53 }
54
55 public static HttpReceive sendGet(String url, Map<String, Object> param) {
56 HttpSend send = new HttpSend(url, param, HttpMethod.GET);
57 return sendHttp(send);
58 }
59
60 public static HttpReceive sendPost(String url, Map<String, Object> param) {
61 HttpSend send = new HttpSend(url, param, HttpMethod.POST);
62 return sendHttp(send);
63 }
64
65 /**
66 * 用于请求http
67 *
68 * @param send
69 * 里面包含请求的信息
70 *
71 * @return 响应的信息
72 */
73 public static HttpReceive sendHttp(HttpSend send) {
74 return sendHttp(send, builder);
75 }
76
77 /**
78 * 用于请求http
79 *
80 * @param send
81 * 里面包含请求的信息
82 *
83 * @return 响应的信息
84 */
85 public static HttpReceive sendHttp(HttpSend send, HttpBuilder httpBuilder) {
86 HttpReceive httpReceive = new HttpReceive();
87 httpReceive.setHaveError(true);
88
89 String url = send.getUrl();
90 URI uri;
91 try {
92 uri = new URL(url).toURI();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected