MCPcopy Create free account
hub / github.com/0x727/DropLabTools / HttpUtils

Class HttpUtils

src/main/java/com/droplab/Utils/HttpUtils.java:34–413  ·  view source on GitHub ↗

Http发送post请求工具,兼容http和https两种请求类型

Source from the content-addressed store, hash-verified

32 * Http发送post请求工具,兼容http和https两种请求类型
33 */
34public class HttpUtils {
35
36 /**
37 * 请求超时时间
38 */
39 private static int TIME_OUT = 120000;
40 public static void set_TIME_OUT(int time_out){
41 TIME_OUT=time_out;
42 }
43
44 /**
45 * Https请求
46 */
47 private static final String HTTPS = "https";
48
49 /**
50 * Content-Type
51 */
52 private static final String CONTENT_TYPE = "Content-Type";
53
54 /**
55 * 表单提交方式Content-Type
56 */
57 private static final String FORM_TYPE = "application/x-www-form-urlencoded;charset=UTF-8";
58
59 /**
60 * JSON提交方式Content-Type
61 */
62 private static final String JSON_TYPE = "application/json;charset=UTF-8";
63
64 /**
65 * 自定义Content-Type
66 */
67 private static String Content_Type="";
68 public static void set_Content_Type(String content_Type){
69 Content_Type=content_Type;
70 }
71
72 /**
73 * 发送Get请求
74 *
75 * @param url 请求URL
76 * @return HTTP响应对象
77 * @throws IOException 程序异常时抛出,由调用者处理
78 */
79 public static Response get(String url) throws IOException {
80 return get(url, null);
81 }
82
83 /**
84 * 发送Get请求
85 *
86 * @param url 请求URL
87 * @param headers 请求头参数
88 * @return HTTP响应对象
89 * @throws IOException 程序异常时抛出,由调用者处理
90 */
91 public static Response get(String url, Map<String, String> headers) throws IOException {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected