public class HttpURLConnectionImpl extends HttpURLConnection implements Policy
connected
field from the superclass. That field
is not used to indicate not whether this URLConnection is
currently connected. Instead, it indicates whether a connection has ever been
attempted. Once a connection has been attempted, certain properties (request
header fields, request method, etc.) are immutable. Test the connection
field on this class for null/non-null to determine of an instance
is currently connected to a server.Modifier and Type | Field and Description |
---|---|
protected HttpEngine |
httpEngine |
protected IOException |
httpEngineFailure |
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, responseMessage
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
Constructor and Description |
---|
HttpURLConnectionImpl(URL url,
OkHttpClient client) |
Modifier and Type | Method and Description |
---|---|
void |
addRequestProperty(String field,
String value) |
void |
connect() |
void |
disconnect() |
int |
getChunkLength() |
int |
getConnectTimeout() |
InputStream |
getErrorStream()
Returns an input stream from the server in the case of error such as the
requested file (txt, htm, html) is not found on the remote server.
|
long |
getFixedContentLength() |
String |
getHeaderField(int position)
Returns the value of the field at
position . |
String |
getHeaderField(String fieldName)
Returns the value of the field corresponding to the
fieldName , or
null if there is no such field. |
String |
getHeaderFieldKey(int position) |
Map<String,List<String>> |
getHeaderFields() |
HttpURLConnection |
getHttpConnectionToCache()
Returns the HttpURLConnection instance to store in the cache.
|
HttpEngine |
getHttpEngine() |
InputStream |
getInputStream() |
OutputStream |
getOutputStream() |
Permission |
getPermission() |
int |
getReadTimeout() |
Map<String,List<String>> |
getRequestProperties() |
String |
getRequestProperty(String field) |
int |
getResponseCode() |
String |
getResponseMessage() |
void |
setConnectTimeout(int timeoutMillis) |
void |
setFixedLengthStreamingMode(int contentLength) |
void |
setFixedLengthStreamingMode(long contentLength) |
void |
setReadTimeout(int timeoutMillis) |
void |
setRequestProperty(String field,
String newValue) |
boolean |
usingProxy()
Returns true if a non-direct proxy is specified.
|
getFollowRedirects, getHeaderFieldDate, getInstanceFollowRedirects, getRequestMethod, setChunkedStreamingMode, setFollowRedirects, setInstanceFollowRedirects, setRequestMethod
getAllowUserInteraction, 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, setIfModifiedSince, setUseCaches, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getIfModifiedSince, getURL, getUseCaches
protected IOException httpEngineFailure
protected HttpEngine httpEngine
public HttpURLConnectionImpl(URL url, OkHttpClient client)
public final void connect() throws IOException
connect
in class URLConnection
IOException
public final void disconnect()
disconnect
in class HttpURLConnection
public final InputStream getErrorStream()
getErrorStream
in class HttpURLConnection
public final String getHeaderField(int position)
position
. Returns null if there
are fewer than position
headers.getHeaderField
in class HttpURLConnection
public final String getHeaderField(String fieldName)
fieldName
, or
null if there is no such field. If the field has multiple values, the
last value is returned.getHeaderField
in class URLConnection
public final String getHeaderFieldKey(int position)
getHeaderFieldKey
in class HttpURLConnection
public final Map<String,List<String>> getHeaderFields()
getHeaderFields
in class URLConnection
public final Map<String,List<String>> getRequestProperties()
getRequestProperties
in class URLConnection
public final InputStream getInputStream() throws IOException
getInputStream
in class URLConnection
IOException
public final OutputStream getOutputStream() throws IOException
getOutputStream
in class URLConnection
IOException
public final Permission getPermission() throws IOException
getPermission
in class HttpURLConnection
IOException
public final String getRequestProperty(String field)
getRequestProperty
in class URLConnection
public void setConnectTimeout(int timeoutMillis)
setConnectTimeout
in class URLConnection
public int getConnectTimeout()
getConnectTimeout
in class URLConnection
public void setReadTimeout(int timeoutMillis)
setReadTimeout
in class URLConnection
public int getReadTimeout()
getReadTimeout
in class URLConnection
public HttpURLConnection getHttpConnectionToCache()
Policy
getHttpConnectionToCache
in interface Policy
public HttpEngine getHttpEngine()
public final long getFixedContentLength()
getFixedContentLength
in interface Policy
HttpURLConnection.setFixedLengthStreamingMode(int)
public final int getChunkLength()
getChunkLength
in interface Policy
HttpURLConnection.setChunkedStreamingMode(int)
public final boolean usingProxy()
Policy
usingProxy
in interface Policy
usingProxy
in class HttpURLConnection
public String getResponseMessage() throws IOException
getResponseMessage
in class HttpURLConnection
IOException
public final int getResponseCode() throws IOException
getResponseCode
in class HttpURLConnection
IOException
public final void setRequestProperty(String field, String newValue)
setRequestProperty
in class URLConnection
public final void addRequestProperty(String field, String value)
addRequestProperty
in class URLConnection
public void setFixedLengthStreamingMode(int contentLength)
setFixedLengthStreamingMode
in class HttpURLConnection
public void setFixedLengthStreamingMode(long contentLength)
setFixedLengthStreamingMode
in class HttpURLConnection
Copyright © 2014. All rights reserved.