public class HttpConnection extends Object
| 构造器和说明 |
|---|
HttpConnection(String urlStr,
Method method)
构造HttpConnection
|
public static HttpConnection create(String urlStr, Method method)
urlStr - URLmethod - HTTP方法public HttpConnection initConn()
public Method getMethod()
public void setMethod(Method method)
method - 请求方法public URL getUrl()
public void setUrl(URL url)
url - 请求URLpublic HttpURLConnection getHttpURLConnection()
public HttpConnection header(String header, String value, boolean isOverride)
header - 头名value - 头值isOverride - 是否覆盖旧值public HttpConnection header(Header header, String value, boolean isOverride)
header - 头名value - 头值isOverride - 是否覆盖旧值public HttpConnection header(Map<String,List<String>> headers)
headers - 请求头public HttpConnection disableCache()
public HttpConnection setConnectTimeout(int timeout)
timeout - 超时public HttpConnection setReadTimeout(int timeout)
timeout - 超时public HttpConnection setConnectionAndReadTimeout(int timeout)
timeout - 超时时间public HttpConnection setCookie(String cookie)
cookie - Cookiepublic HttpConnection setChunkedStreamingMode(int blockSize)
blockSize - 块大小(bytes数)public HttpConnection connect() throws IOException
IOExceptionpublic HttpConnection disconnect()
public InputStream getInputStream() throws IOException
IOExceptionpublic OutputStream getOutputStream() throws IOException
IOExceptionpublic int responseCode()
throws IOException
IOExceptionpublic String charset()
Copyright © 2015. All rights reserved.