public class Http extends Object
限定符和类型 | 类和说明 |
---|---|
static class |
Http.multipart |
限定符和类型 | 字段和说明 |
---|---|
protected static boolean |
autoSwitch |
static HashMap<String,String> |
DEFAULT_HEADERS |
protected static ProxySwitcher |
proxySwitcher |
protected static SSLSocketFactory |
sslSocketFactory |
构造器和说明 |
---|
Http() |
限定符和类型 | 方法和说明 |
---|---|
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,
int timeout)
访问一个URL,并设置超时
|
static Response |
get(String url,
Map<String,Object> params,
int timeout) |
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,
String inenc,
String reenc) |
static Response |
post2(String url,
Map<String,Object> params,
int timeout)
访问一个URL,并设置超时及参数
|
static Response |
post3(String url,
Object body,
Header header,
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)
已过时。
|
static void |
setSSLSocketFactory(SSLSocketFactory sslSocketFactory) |
static Response |
upload(String url,
Map<String,Object> params,
Header header,
int timeout) |
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 upload(String url, Map<String,Object> params, Header header, int timeout)
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.