MCPcopy Create free account
hub / github.com/FongMi/CatVodSpider / OkHttp

Class OkHttp

app/src/main/java/com/github/catvod/net/OkHttp.java:26–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24import okhttp3.Response;
25
26public class OkHttp {
27
28 private static final long TIMEOUT = TimeUnit.SECONDS.toMillis(15);
29
30 public static final String POST = "POST";
31 public static final String GET = "GET";
32
33 private OkHttpClient client;
34
35 private static class Loader {
36 static volatile OkHttp INSTANCE = new OkHttp();
37 }
38
39 private static OkHttp get() {
40 return Loader.INSTANCE;
41 }
42
43 public static Response newCall(String url, String tag) throws IOException {
44 return client().newCall(new Request.Builder().url(url).tag(tag).build()).execute();
45 }
46
47 public static String string(String url) {
48 return string(url, null);
49 }
50
51 public static String string(String url, long timeout) {
52 return string(url, null, null, timeout);
53 }
54
55 public static String string(String url, Map<String, String> header) {
56 return string(url, null, header);
57 }
58
59 public static String string(String url, Map<String, String> params, Map<String, String> header) {
60 return new OkRequest(GET, url, params, header).execute(client()).getBody();
61 }
62
63 public static String string(String url, Map<String, String> params, Map<String, String> header, long timeout) {
64 return new OkRequest(GET, url, params, header).execute(client(timeout)).getBody();
65 }
66
67 public static String post(String url, Map<String, String> params) {
68 return post(url, params, null).getBody();
69 }
70
71 public static OkResult post(String url, Map<String, String> params, Map<String, String> header) {
72 return new OkRequest(POST, url, params, header).execute(client());
73 }
74
75 public static String post(String url, String json) {
76 return post(url, json, null).getBody();
77 }
78
79 public static OkResult post(String url, String json, Map<String, String> header) {
80 return new OkRequest(POST, url, json, header).execute(client());
81 }
82
83 public static String getLocation(String url, Map<String, String> header) throws IOException {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected