Repository navigation
Expand file tree
/
Copy pathIHttpClient.java
More file actions
59 lines (41 loc) · 2.4 KB
/
Copy pathIHttpClient.java
File metadata and controls
59 lines (41 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package cn.jpush.api.common;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public interface IHttpClient {
public static final String CHARSET = "UTF-8";
public static final String CONTENT_TYPE_JSON = "application/json";
public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded";
public static final String RATE_LIMIT_QUOTA = "X-Rate-Limit-Limit";
public static final String RATE_LIMIT_Remaining = "X-Rate-Limit-Remaining";
public static final String RATE_LIMIT_Reset = "X-Rate-Limit-Reset";
public static final String JPUSH_USER_AGENT = "JPush-API-Java-Client";
public static final int RESPONSE_OK = 200;
public enum RequestMethod {
GET,
POST,
DELETE
}
public static final String IO_ERROR_MESSAGE = "Connection IO error. \n"
+ "Can not connect to JPush Server. "
+ "Please ensure your internet connection is ok. \n"
+ "If the problem persists, please let us know at support@jpush.cn.";
public static final String CONNECT_TIMED_OUT_MESSAGE = "connect timed out. \n"
+ "Connect to JPush Server timed out, and already retried some times. \n"
+ "Please ensure your internet connection is ok. \n"
+ "If the problem persists, please let us know at support@jpush.cn.";
public static final String READ_TIMED_OUT_MESSAGE = "Read timed out. \n"
+ "Read response from JPush Server timed out. \n"
+ "If this is a Push action, you may not want to retry. \n"
+ "It may be due to slowly response from JPush server, or unstable connection. \n"
+ "If the problem persists, please let us know at support@jpush.cn.";
public static Gson _gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
//设置连接超时时间
public static final int DEFAULT_CONNECTION_TIMEOUT = (5 * 1000); // milliseconds
//设置读取超时时间
public static final int DEFAULT_READ_TIMEOUT = (30 * 1000); // milliseconds
public static final int DEFAULT_MAX_RETRY_TIMES = 3;
public ResponseWrapper sendGet(String url, String params,
String authCode) throws APIConnectionException, APIRequestException;
public ResponseWrapper sendPost(String url, String content,
String authCode) throws APIConnectionException, APIRequestException;
}