MCPcopy Create free account
hub / github.com/0linlin0/CyberBox / HttpUtils

Class HttpUtils

Skay_Exp/src/tools/HttpUtils.java:18–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16import java.util.Map.Entry;
17
18public class HttpUtils {
19 /**
20 * ����ʱʱ��
21 */
22 private static final int TIME_OUT = 15000;
23
24 /**
25 * Https����
26 */
27 private static final String HTTPS = "https";
28
29 /**
30 * Content-Type
31 */
32 private static final String CONTENT_TYPE = "Content-Type";
33
34 /**
35 * ���ύ��ʽContent-Type
36 */
37 private static final String FORM_TYPE = "application/x-www-form-urlencoded;charset=UTF-8";
38
39 /**
40 * JSON�ύ��ʽContent-Type
41 */
42 private static final String JSON_TYPE = "application/json;charset=UTF-8";
43
44 /**
45 * ����Get����
46 *
47 * @param url ����URL
48 * @return HTTP��Ӧ����
49 * @throws IOException �����쳣ʱ�׳����ɵ����ߴ���
50 */
51 public static Response get(String url) throws IOException {
52 return get(url, null);
53 }
54
55 /**
56 * ����Get����
57 *
58 * @param url ����URL
59 * @param headers ����ͷ����
60 * @return HTTP��Ӧ����
61 * @throws IOException �����쳣ʱ�׳����ɵ����ߴ���
62 */
63 public static Response get(String url, Map<String, String> headers) throws IOException {
64 if (null == url || url.isEmpty()) {
65 throw new RuntimeException("The request URL is blank.");
66 }
67
68 // �����Https����
69 if (url.startsWith(HTTPS)) {
70 getTrust();
71 }
72 Connection connection = Jsoup.connect(url);
73 connection.method(Method.GET);
74 connection.timeout(TIME_OUT);
75 connection.ignoreHttpErrors(true);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected