public final class HttpURLConnection extends HttpURLConnection implements Callback
| Modifier and Type | Field and Description |
|---|---|
static String |
RESPONSE_SOURCE
合成响应标头:加载响应的位置
|
static String |
SELECTED_PROTOCOL
合成响应头:选择(@link Protocol)(“spdy/3.1”、“http/1.1”等)
|
chunkLength, fixedContentLengthLong, HTTP_ACCEPTED, HTTP_BAD_GATEWAY, HTTP_BAD_METHOD, HTTP_BAD_REQUEST, HTTP_CLIENT_TIMEOUT, HTTP_CONFLICT, HTTP_CREATED, HTTP_ENTITY_TOO_LARGE, HTTP_FORBIDDEN, HTTP_GATEWAY_TIMEOUT, HTTP_GONE, HTTP_INTERNAL_ERROR, HTTP_LENGTH_REQUIRED, HTTP_MOVED_PERM, HTTP_MOVED_TEMP, HTTP_MULT_CHOICE, HTTP_NO_CONTENT, HTTP_NOT_ACCEPTABLE, HTTP_NOT_AUTHORITATIVE, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_NOT_MODIFIED, HTTP_OK, HTTP_PARTIAL, HTTP_PAYMENT_REQUIRED, HTTP_PRECON_FAILED, HTTP_PROXY_AUTH, HTTP_REQ_TOO_LONG, HTTP_RESET, HTTP_SEE_OTHER, HTTP_SERVER_ERROR, HTTP_UNAUTHORIZED, HTTP_UNAVAILABLE, HTTP_UNSUPPORTED_TYPE, HTTP_USE_PROXY, HTTP_VERSION, instanceFollowRedirects, method, responseCode, responseMessageallowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches| Constructor and Description |
|---|
HttpURLConnection(URL url,
Httpd client) |
HttpURLConnection(URL url,
Httpd client,
Interceptor urlFilter) |
getFollowRedirects, getHeaderFieldDate, getRequestMethod, setChunkedStreamingMode, setFollowRedirectsgetAllowUserInteraction, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderFieldInt, getHeaderFieldLong, getIfModifiedSince, getLastModified, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setUseCaches, toStringpublic static final String SELECTED_PROTOCOL
public static final String RESPONSE_SOURCE
public HttpURLConnection(URL url, Httpd client, Interceptor urlFilter)
public static Map<String,List<String>> toMultimap(Headers headers, String valueForNullKey)
public void connect()
throws IOException
connect in class URLConnectionIOExceptionpublic void disconnect()
disconnect in class HttpURLConnectionpublic InputStream getErrorStream()
getErrorStream in class HttpURLConnectionpublic String getHeaderField(int position)
getHeaderField in class HttpURLConnectionpublic String getHeaderField(String fieldName)
getHeaderField in class URLConnectionpublic String getHeaderFieldKey(int position)
getHeaderFieldKey in class HttpURLConnectionpublic Map<String,List<String>> getHeaderFields()
getHeaderFields in class URLConnectionpublic Map<String,List<String>> getRequestProperties()
getRequestProperties in class URLConnectionpublic InputStream getInputStream() throws IOException
getInputStream in class URLConnectionIOExceptionpublic OutputStream getOutputStream() throws IOException
getOutputStream in class URLConnectionIOExceptionpublic Permission getPermission()
getPermission in class HttpURLConnectionpublic String getRequestProperty(String field)
getRequestProperty in class URLConnectionpublic boolean getInstanceFollowRedirects()
getInstanceFollowRedirects in class HttpURLConnectionpublic void setInstanceFollowRedirects(boolean followRedirects)
setInstanceFollowRedirects in class HttpURLConnectionpublic int getConnectTimeout()
getConnectTimeout in class URLConnectionpublic void setConnectTimeout(int timeoutMillis)
setConnectTimeout in class URLConnectionpublic int getReadTimeout()
getReadTimeout in class URLConnectionpublic void setReadTimeout(int timeoutMillis)
setReadTimeout in class URLConnectionpublic boolean usingProxy()
usingProxy in class HttpURLConnectionpublic String getResponseMessage() throws IOException
getResponseMessage in class HttpURLConnectionIOExceptionpublic int getResponseCode()
throws IOException
getResponseCode in class HttpURLConnectionIOExceptionpublic void setRequestProperty(String field, String newValue)
setRequestProperty in class URLConnectionpublic void setIfModifiedSince(long newValue)
setIfModifiedSince in class URLConnectionpublic void addRequestProperty(String field, String value)
addRequestProperty in class URLConnectionpublic void setRequestMethod(String method) throws ProtocolException
setRequestMethod in class HttpURLConnectionProtocolExceptionpublic void setFixedLengthStreamingMode(int contentLength)
setFixedLengthStreamingMode in class HttpURLConnectionpublic void setFixedLengthStreamingMode(long contentLength)
setFixedLengthStreamingMode in class HttpURLConnectionpublic void onFailure(NewCall call, IOException e)
Callbackpublic void onResponse(NewCall call, Response response)
CallbackResponse.body读取响应体响应仍然是活动的
直到它的响应体是closed 回调的接收者可以使用另一个线程上的响应体
注意,传输层的成功(接收HTTP响应代码、报头和正文)不一定表示应用程序层的
成功:response可能仍然表示不满意的HTTP响应代码,如404或500onResponse in interface Callbackcall - 调用者信息response - 响应体Copyright © 2020. All rights reserved.