public class HttpClient extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected long |
appId |
protected String |
appSecret |
protected Random |
random |
static String |
SIGN |
protected boolean |
useSSL
是否使用https接口调用:true 使用https连接,false使用http连接;默认使用http
|
| 构造器和说明 |
|---|
HttpClient(long appId,
String appSecret) |
HttpClient(long appId,
String appSecret,
boolean useSSL) |
HttpClient(String appSecret) |
HttpClient(String appSecret,
boolean useSSL) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected static void |
addParameter(StringBuilder body,
String name,
String value) |
HttpURLConnection |
doGet(String url,
String parameter) |
protected HttpURLConnection |
doGet(String url,
String contentType,
String parameter) |
protected HttpURLConnection |
doPost(String url,
String body) |
protected HttpURLConnection |
doPost(String url,
String contentType,
String body) |
static String |
getAndClose(InputStream stream) |
protected HttpURLConnection |
getConnection(String url) |
protected static String |
getString(InputStream stream) |
protected static StringBuilder |
newBody(String name,
String value) |
protected static StringBuilder |
newBodyWithArrayParameters(String name,
List<String> parameters) |
protected static <T> T |
nonNull(T argument) |
protected HttpResult |
post(boolean useSSL,
String url,
String body)
超时以及服务不可用异常返回null
|
protected void |
prepareConnection(HttpURLConnection conn) |
protected void |
sleep(long millis) |
protected final Random random
protected final String appSecret
protected final long appId
protected final boolean useSSL
public HttpClient(String appSecret)
public HttpClient(String appSecret, boolean useSSL)
public HttpClient(long appId,
String appSecret)
public HttpClient(long appId,
String appSecret,
boolean useSSL)
protected HttpURLConnection doPost(String url, String body) throws IOException
IOExceptionpublic HttpURLConnection doGet(String url, String parameter) throws IOException
IOExceptionprotected HttpURLConnection doPost(String url, String contentType, String body) throws IOException
IOExceptionprotected HttpURLConnection doGet(String url, String contentType, String parameter) throws IOException
IOExceptionprotected void prepareConnection(HttpURLConnection conn)
protected static StringBuilder newBody(String name, String value) throws UnsupportedEncodingException
protected static StringBuilder newBodyWithArrayParameters(String name, List<String> parameters) throws UnsupportedEncodingException
protected static void addParameter(StringBuilder body, String name, String value) throws UnsupportedEncodingException
protected HttpURLConnection getConnection(String url) throws IOException
IOExceptionprotected static String getString(InputStream stream) throws IOException
IOExceptionpublic static String getAndClose(InputStream stream) throws IOException
IOExceptionprotected static <T> T nonNull(T argument)
protected void sleep(long millis)
protected HttpResult post(boolean useSSL, String url, String body) throws IOException
useSSL - 是否启用httpsurl - body - IOExceptionCopyright © 2016–2023 MEIZUPUSH Group. All rights reserved.