public class HttpConnection extends Object
| 限定符和类型 | 类和说明 |
|---|---|
class |
HttpConnection.TrustAnyHostnameVerifier
https 域名校验
|
| 构造器和说明 |
|---|
HttpConnection(String url,
String method)
初始化HttpConnection
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
connect()
连接
|
void |
disconnect()
断开连接
|
Map<String,List<String>> |
getHeaderFields()
获取请求头信息
|
HttpsURLConnection |
getHttpsURLConnection()
获取HttpsURLConnection对象
|
HttpURLConnection |
getHttpURLConnection()
获取HttpURLConnection对象
|
InputStream |
getInputStream() |
String |
getMethod()
获取请求方法,GET/POST
|
OutputStream |
getOutputStream()
获取输出流对象
|
int |
getResponseCode()
获取响应码
|
int |
getTimeout()
获取超时
|
String |
getUrl()
获取请求URL
|
void |
setConnectTimeout(int timeout)
设置连接超时
|
void |
setMethod(String method)
设置请求方法
|
void |
setReadTimeout(int timeout)
设置读取超时
|
void |
setRequestProperty(Map<String,List<String>> headers)
设置请求头
|
void |
setRequestProperty(String key,
String value)
设置请求头
|
void |
setTimeout(int timeout)
设置超时
|
void |
setUrl(String url)
设置请求URL
|
public HttpConnection(String url, String method) throws IOException, KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException
url - method - IOExceptionKeyManagementExceptionNoSuchAlgorithmExceptionNoSuchProviderExceptionpublic String getMethod()
public void setMethod(String method)
method - public String getUrl()
public void setUrl(String url)
url - public int getTimeout()
public void setTimeout(int timeout)
timeout - public HttpsURLConnection getHttpsURLConnection()
public HttpURLConnection getHttpURLConnection()
public void setConnectTimeout(int timeout)
timeout - public void setReadTimeout(int timeout)
timeout - public void setRequestProperty(Map<String,List<String>> headers)
headers - public void connect()
throws IOException
IOExceptionpublic void disconnect()
public InputStream getInputStream() throws IOException
IOExceptionpublic OutputStream getOutputStream() throws IOException
IOExceptionpublic int getResponseCode()
throws IOException
IOExceptionCopyright © 2015. All rights reserved.