public class Http extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Http.multipart |
Modifier and Type | Field and Description |
---|---|
protected static boolean |
autoSwitch |
static HashMap<String,String> |
DEFAULT_HEADERS |
protected static ProxySwitcher |
proxySwitcher |
protected static SSLSocketFactory |
sslSocketFactory |
Constructor and Description |
---|
Http() |
Modifier and Type | Method and Description |
---|---|
static boolean |
disableJvmHttpsCheck()
禁用JVM的https证书验证机制, 例如访问12306, 360 openapi之类的自签名证书
|
static String |
encode(Object s) |
static String |
encode(Object s,
String enc) |
static Response |
get(String url)
访问一个URL
|
static Response |
get(String url,
Header header,
int timeout) |
static Response |
get(String url,
Header header,
int timeout,
int connTimeout) |
static Response |
get(String url,
int timeout)
访问一个URL,并设置超时
|
static Response |
get(String url,
int timeout,
int connTimeout) |
static Response |
get(String url,
Map<String,Object> params,
int timeout) |
static Response |
get(String url,
Map<String,Object> params,
int timeout,
int connTimeout) |
static ProxySwitcher |
getProxySwitcher() |
static String |
getStatusText(int statusCode) |
static String |
getStatusText(int statusCode,
String dft) |
static SSLSocketFactory |
nopSSLSocketFactory() |
static String |
post(String url,
Map<String,Object> params,
int timeout)
访问一个URL,并设置超时及参数
|
static String |
post(String url,
Map<String,Object> params,
int timeout,
int connTimeout) |
static String |
post(String url,
Map<String,Object> params,
String inenc,
String reenc) |
static Response |
post2(String url,
Map<String,Object> params,
int timeout)
访问一个URL,并设置超时及参数
|
static Response |
post2(String url,
Map<String,Object> params,
int timeout,
int connTimeout) |
static Response |
post3(String url,
Object body,
Header header,
int timeout) |
static Response |
post3(String url,
Object body,
Header header,
int timeout,
int connTimeout) |
static Response |
postXML(String url,
String xml,
int timeout) |
static void |
setAutoSwitch(boolean use) |
static void |
setHttpProxy(String host,
int port) |
static void |
setProxySwitcher(ProxySwitcher proxySwitcher) |
static void |
setSocketProxy(String host,
int port) |
static void |
setSocktProxy(String host,
int port)
Deprecated.
|
static void |
setSSLSocketFactory(SSLSocketFactory sslSocketFactory) |
static Response |
upload(String url,
Map<String,Object> params,
Header header,
int timeout) |
static Response |
upload(String url,
Map<String,Object> params,
Header header,
int timeout,
int connTimeout) |
protected static ProxySwitcher proxySwitcher
protected static boolean autoSwitch
protected static SSLSocketFactory sslSocketFactory
public static String getStatusText(int statusCode)
public static Response get(String url, int timeout)
url
- 需要访问的URLtimeout
- 超时设置,单位为毫秒public static String post(String url, Map<String,Object> params, int timeout)
url
- 需要访问的URLparams
- 参数timeout
- 超时设置,单位为毫秒public static Response post2(String url, Map<String,Object> params, int timeout)
url
- 需要访问的URLparams
- 参数timeout
- 超时设置,单位为毫秒public static Response post2(String url, Map<String,Object> params, int timeout, int connTimeout)
public static Response post3(String url, Object body, Header header, int timeout, int connTimeout)
public static Response upload(String url, Map<String,Object> params, Header header, int timeout)
public static Response upload(String url, Map<String,Object> params, Header header, int timeout, int connTimeout)
public static void setAutoSwitch(boolean use)
public static void setHttpProxy(String host, int port)
@Deprecated public static void setSocktProxy(String host, int port)
public static void setSocketProxy(String host, int port)
public static ProxySwitcher getProxySwitcher()
public static void setProxySwitcher(ProxySwitcher proxySwitcher)
public static boolean disableJvmHttpsCheck()
public static SSLSocketFactory nopSSLSocketFactory() throws Exception
Exception
public static void setSSLSocketFactory(SSLSocketFactory sslSocketFactory)
Copyright © 2017. All rights reserved.