Class HttpsURLConnectionImpl
public final class HttpsURLConnectionImpl extends HttpsURLConnection
-
Field Summary
Fields inherited from class javax.net.ssl.HttpsURLConnection
hostnameVerifierFields inherited from class java.net.HttpURLConnection
chunkLength, fixedContentLength, 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, responseMessageFields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches -
Constructor Summary
Constructors Constructor Description HttpsURLConnectionImpl(URL url, OkHttpClient client) -
Method Summary
Modifier and Type Method Description voidaddRequestProperty(String field, String newValue)Adds the given property to the request header.voidconnect()Opens a connection to the resource.voiddisconnect()Releases this connection so that its resources may be either reused or closed.booleangetAllowUserInteraction()ReturnsallowUserInteraction.StringgetCipherSuite()Returns the name of the cipher suite negotiated during the SSL handshake.intgetConnectTimeout()Returns the connect timeout in milliseconds.ObjectgetContent()Returns an object representing the content of the resource thisURLConnectionis connected to.ObjectgetContent(Class[] types)Returns an object representing the content of the resource thisURLConnectionis connected to.StringgetContentEncoding()Returns the encoding used to transmit the response body over the network.intgetContentLength()Returns the content length in bytes specified by the response header fieldcontent-lengthor-1if this field is not set.StringgetContentType()Returns the MIME-type of the content specified by the response header fieldcontent-typeornullif type is unknown.longgetDate()Returns the timestamp when this response has been sent as a date in milliseconds since January 1, 1970 GMT or0if this timestamp is unknown.booleangetDefaultUseCaches()Returns the default setting whether this connection allows using caches.booleangetDoInput()Returns the value of the optiondoInputwhich specifies whether this connection allows to receive data.booleangetDoOutput()Returns the value of the optiondoOutputwhich specifies whether this connection allows to send data.InputStreamgetErrorStream()Returns an input stream from the server in the case of an error such as the requested file has not been found on the remote server.longgetExpiration()Returns the timestamp when this response will be expired in milliseconds since January 1, 1970 GMT or0if this timestamp is unknown.StringgetHeaderField(int pos)Returns the header value at the field positionposornullif the header has fewer thanposfields.StringgetHeaderField(String key)Returns the value of the header field specified bykeyornullif there is no field with this name.longgetHeaderFieldDate(String field, long defaultValue)Returns the date value in milliseconds since01.01.1970, 00:00hcorresponding to the header fieldfield.intgetHeaderFieldInt(String field, int defaultValue)Returns the specified header value as a number.StringgetHeaderFieldKey(int position)Returns the name of the header field at the given positionposnornullif there are fewer thanposnfields.Map<String,List<String>>getHeaderFields()Returns an unmodifiable map of the response-header fields and values.HostnameVerifiergetHostnameVerifier()Returns the hostname verifier used by this instance.HttpEnginegetHttpEngine()longgetIfModifiedSince()Returns the point of time since when the data must be modified to be transmitted.InputStreamgetInputStream()Returns anInputStreamfor reading data from the resource pointed by thisURLConnection.booleangetInstanceFollowRedirects()Returns whether this connection follows redirects.longgetLastModified()Returns the value of the response header fieldlast-modifiedor0if this value is not set.Certificate[]getLocalCertificates()Returns the list of local certificates used during the handshake.PrincipalgetLocalPrincipal()Returns thePrincipalused to identify the local host during the handshake.OutputStreamgetOutputStream()Returns anOutputStreamfor writing data to thisURLConnection.PrincipalgetPeerPrincipal()Returns thePrincipalidentifying the peer.PermissiongetPermission()Returns the permission object (in this caseSocketPermission) with the host and the port number as the target name and"resolve, connect"as the action list.intgetReadTimeout()Returns the read timeout in milliseconds, or0if reads never timeout.StringgetRequestMethod()Returns the request method which will be used to make the request to the remote HTTP server.Map<String,List<String>>getRequestProperties()Returns an unmodifiable map of general request properties used by this connection.StringgetRequestProperty(String field)Returns the value of the request header property specified by {code field} ornullif there is no field with this name.intgetResponseCode()Returns the response code returned by the remote HTTP server.StringgetResponseMessage()Returns the response message returned by the remote HTTP server.Certificate[]getServerCertificates()Return the list of certificates identifying the peer during the handshake.SSLSocketFactorygetSSLSocketFactory()Returns the SSL socket factory used by this instance.URLgetURL()Returns the URL represented by thisURLConnection.booleangetUseCaches()Returns the value of the flag which specifies whether thisURLConnectionallows to use caches.voidsetAllowUserInteraction(boolean newValue)SetsallowUserInteraction.voidsetChunkedStreamingMode(int chunkLength)Stream a request body whose length is not known in advance.voidsetConnectTimeout(int timeoutMillis)Sets the maximum time in milliseconds to wait while connecting.voidsetDefaultUseCaches(boolean newValue)Sets the default value for the flag indicating whether this connection allows to use caches.voidsetDoInput(boolean newValue)Sets the flag indicating whether thisURLConnectionallows input.voidsetDoOutput(boolean newValue)Sets the flag indicating whether thisURLConnectionallows output.voidsetFixedLengthStreamingMode(int contentLength)Equivalent tosetFixedLengthStreamingMode((long) contentLength), but available on earlier versions of Android and limited to 2 GiB.voidsetHostnameVerifier(HostnameVerifier hostnameVerifier)Sets the hostname verifier for this instance.voidsetIfModifiedSince(long newValue)Sets the point of time since when the data must be modified to be transmitted.voidsetInstanceFollowRedirects(boolean followRedirects)Sets whether this connection follows redirects.voidsetReadTimeout(int timeoutMillis)Sets the maximum time to wait for an input stream read to complete before giving up.voidsetRequestMethod(String method)Sets the request command which will be sent to the remote HTTP server.voidsetRequestProperty(String field, String newValue)Sets the value of the specified request header field.voidsetSSLSocketFactory(SSLSocketFactory sslSocketFactory)Sets the SSL socket factory for this instance.voidsetUseCaches(boolean newValue)Sets the flag indicating whether this connection allows to use caches or not.StringtoString()Returns the string representation containing the name of this class and the URL.booleanusingProxy()Returns whether this connection uses a proxy server or not.Methods inherited from class javax.net.ssl.HttpsURLConnection
getDefaultHostnameVerifier, getDefaultSSLSocketFactory, setDefaultHostnameVerifier, setDefaultSSLSocketFactoryMethods inherited from class java.net.HttpURLConnection
getFollowRedirects, setFixedLengthStreamingMode, setFollowRedirects
-
Constructor Details
-
HttpsURLConnectionImpl
-
-
Method Details
-
getCipherSuite
Description copied from class:HttpsURLConnectionReturns the name of the cipher suite negotiated during the SSL handshake.- Specified by:
getCipherSuitein classHttpsURLConnection- Returns:
- the name of the cipher suite negotiated during the SSL handshake.
-
getLocalCertificates
Description copied from class:HttpsURLConnectionReturns the list of local certificates used during the handshake. These certificates were sent to the peer.- Specified by:
getLocalCertificatesin classHttpsURLConnection- Returns:
- Returns the list of certificates used during the handshake with
the local identity certificate followed by CAs, or
nullif no certificates were used during the handshake.
-
getServerCertificates
Description copied from class:HttpsURLConnectionReturn the list of certificates identifying the peer during the handshake.- Specified by:
getServerCertificatesin classHttpsURLConnection- Returns:
- the list of certificates identifying the peer with the peer's identity certificate followed by CAs.
- Throws:
SSLPeerUnverifiedException- if the identity of the peer has not been verified..
-
getPeerPrincipal
Description copied from class:HttpsURLConnectionReturns thePrincipalidentifying the peer.- Overrides:
getPeerPrincipalin classHttpsURLConnection- Returns:
- the
Principalidentifying the peer. - Throws:
SSLPeerUnverifiedException- if the identity of the peer has not been verified.
-
getLocalPrincipal
Description copied from class:HttpsURLConnectionReturns thePrincipalused to identify the local host during the handshake.- Overrides:
getLocalPrincipalin classHttpsURLConnection- Returns:
- the
Principalused to identify the local host during the handshake, ornullif none was used.
-
getHttpEngine
-
disconnect
public void disconnect()Description copied from class:HttpURLConnectionReleases this connection so that its resources may be either reused or closed.Unlike other Java implementations, this will not necessarily close socket connections that can be reused. You can disable all connection reuse by setting the
http.keepAlivesystem property tofalsebefore issuing any HTTP requests.- Specified by:
disconnectin classHttpURLConnection
-
getErrorStream
Description copied from class:HttpURLConnectionReturns an input stream from the server in the case of an error such as the requested file has not been found on the remote server. This stream can be used to read the data the server will send back.- Overrides:
getErrorStreamin classHttpURLConnection- Returns:
- the error input stream returned by the server.
-
getRequestMethod
Description copied from class:HttpURLConnectionReturns the request method which will be used to make the request to the remote HTTP server. All possible methods of this HTTP implementation is listed in the class definition.- Overrides:
getRequestMethodin classHttpURLConnection- Returns:
- the request method string.
- See Also:
HttpURLConnection.method,HttpURLConnection.setRequestMethod(java.lang.String)
-
getResponseCode
Description copied from class:HttpURLConnectionReturns the response code returned by the remote HTTP server.- Overrides:
getResponseCodein classHttpURLConnection- Returns:
- the response code, -1 if no valid response code.
- Throws:
IOException- if there is an IO error during the retrieval.- See Also:
HttpURLConnection.getResponseMessage()
-
getResponseMessage
Description copied from class:HttpURLConnectionReturns the response message returned by the remote HTTP server.- Overrides:
getResponseMessagein classHttpURLConnection- Returns:
- the response message.
nullif no such response exists. - Throws:
IOException- if there is an error during the retrieval.- See Also:
HttpURLConnection.getResponseCode()
-
setRequestMethod
Description copied from class:HttpURLConnectionSets the request command which will be sent to the remote HTTP server. This method can only be called before the connection is made.- Overrides:
setRequestMethodin classHttpURLConnection- Parameters:
method- the string representing the method to be used.- Throws:
ProtocolException- if this is called after connected, or the method is not supported by this HTTP implementation.- See Also:
HttpURLConnection.getRequestMethod(),HttpURLConnection.method
-
usingProxy
public boolean usingProxy()Description copied from class:HttpURLConnectionReturns whether this connection uses a proxy server or not.- Specified by:
usingProxyin classHttpURLConnection- Returns:
trueif this connection passes a proxy server, false otherwise.
-
getInstanceFollowRedirects
public boolean getInstanceFollowRedirects()Description copied from class:HttpURLConnectionReturns whether this connection follows redirects.- Overrides:
getInstanceFollowRedirectsin classHttpURLConnection- Returns:
trueif this connection follows redirects, false otherwise.
-
setInstanceFollowRedirects
public void setInstanceFollowRedirects(boolean followRedirects)Description copied from class:HttpURLConnectionSets whether this connection follows redirects.- Overrides:
setInstanceFollowRedirectsin classHttpURLConnection- Parameters:
followRedirects-trueif this connection will follows redirects, false otherwise.
-
connect
Description copied from class:URLConnectionOpens a connection to the resource. This method will not reconnect to a resource after the initial connection has been closed.- Specified by:
connectin classURLConnection- Throws:
IOException- if an error occurs while connecting to the resource.
-
getAllowUserInteraction
public boolean getAllowUserInteraction()Description copied from class:URLConnectionReturnsallowUserInteraction. Unused by Android.- Overrides:
getAllowUserInteractionin classURLConnection
-
getContent
Description copied from class:URLConnectionReturns an object representing the content of the resource thisURLConnectionis connected to. First, it attempts to get the content type from the methodgetContentType()which looks at the response header field "Content-Type". If none is found it will guess the content type from the filename extension. If that fails the stream itself will be used to guess the content type.- Overrides:
getContentin classURLConnection- Returns:
- the content representing object.
- Throws:
IOException- if an error occurs obtaining the content.
-
getContent
Description copied from class:URLConnectionReturns an object representing the content of the resource thisURLConnectionis connected to. First, it attempts to get the content type from the methodgetContentType()which looks at the response header field "Content-Type". If none is found it will guess the content type from the filename extension. If that fails the stream itself will be used to guess the content type. The content type must match with one of the listtypes.- Overrides:
getContentin classURLConnection- Parameters:
types- the list of acceptable content types.- Returns:
- the content representing object or
nullif the content type does not match with one of the specified types. - Throws:
IOException- if an error occurs obtaining the content.
-
getContentEncoding
Description copied from class:HttpURLConnectionReturns the encoding used to transmit the response body over the network. This is null or "identity" if the content was not encoded, or "gzip" if the body was gzip compressed. Most callers will be more interested in thecontent type, which may also include the content's character encoding.- Overrides:
getContentEncodingin classHttpURLConnection- Returns:
- the value of the response header field
content-encoding.
-
getContentLength
public int getContentLength()Description copied from class:URLConnectionReturns the content length in bytes specified by the response header fieldcontent-lengthor-1if this field is not set.- Overrides:
getContentLengthin classURLConnection- Returns:
- the value of the response header field
content-length.
-
getContentType
Description copied from class:URLConnectionReturns the MIME-type of the content specified by the response header fieldcontent-typeornullif type is unknown.- Overrides:
getContentTypein classURLConnection- Returns:
- the value of the response header field
content-type.
-
getDate
public long getDate()Description copied from class:URLConnectionReturns the timestamp when this response has been sent as a date in milliseconds since January 1, 1970 GMT or0if this timestamp is unknown.- Overrides:
getDatein classURLConnection- Returns:
- the sending timestamp of the current response.
-
getDefaultUseCaches
public boolean getDefaultUseCaches()Description copied from class:URLConnectionReturns the default setting whether this connection allows using caches.- Overrides:
getDefaultUseCachesin classURLConnection- Returns:
- the value of the default setting
defaultUseCaches. - See Also:
URLConnection.useCaches
-
getDoInput
public boolean getDoInput()Description copied from class:URLConnectionReturns the value of the optiondoInputwhich specifies whether this connection allows to receive data.- Overrides:
getDoInputin classURLConnection- Returns:
trueif this connection allows input,falseotherwise.- See Also:
URLConnection.doInput
-
getDoOutput
public boolean getDoOutput()Description copied from class:URLConnectionReturns the value of the optiondoOutputwhich specifies whether this connection allows to send data.- Overrides:
getDoOutputin classURLConnection- Returns:
trueif this connection allows output,falseotherwise.- See Also:
URLConnection.doOutput
-
getExpiration
public long getExpiration()Description copied from class:URLConnectionReturns the timestamp when this response will be expired in milliseconds since January 1, 1970 GMT or0if this timestamp is unknown.- Overrides:
getExpirationin classURLConnection- Returns:
- the value of the response header field
expires.
-
getHeaderField
Description copied from class:URLConnectionReturns the header value at the field positionposornullif the header has fewer thanposfields. The base implementation of this method returns alwaysnull.Some implementations (notably
HttpURLConnection) include a mapping for the null key; in HTTP's case, this maps to the HTTP status line and is treated as being at position 0 when indexing into the header fields.- Overrides:
getHeaderFieldin classURLConnection- Parameters:
pos- the field position of the response header.- Returns:
- the value of the field at position
pos.
-
getHeaderFields
Description copied from class:URLConnectionReturns an unmodifiable map of the response-header fields and values. The response-header field names are the key values of the map. The map values are lists of header field values associated with a particular key name.Some implementations (notably
HttpURLConnection) include a mapping for the null key; in HTTP's case, this maps to the HTTP status line and is treated as being at position 0 when indexing into the header fields.- Overrides:
getHeaderFieldsin classURLConnection- Returns:
- the response-header representing generic map.
-
getRequestProperties
Description copied from class:URLConnectionReturns an unmodifiable map of general request properties used by this connection. The request property names are the key values of the map. The map values are lists of property values of the corresponding key name.- Overrides:
getRequestPropertiesin classURLConnection- Returns:
- the request-property representing generic map.
-
addRequestProperty
Description copied from class:URLConnectionAdds the given property to the request header. Existing properties with the same name will not be overwritten by this method.- Overrides:
addRequestPropertyin classURLConnection- Parameters:
field- the request property field name to add.newValue- the value of the property which is to add.
-
getHeaderField
Description copied from class:URLConnectionReturns the value of the header field specified bykeyornullif there is no field with this name. The base implementation of this method returns alwaysnull.Some implementations (notably
HttpURLConnection) include a mapping for the null key; in HTTP's case, this maps to the HTTP status line and is treated as being at position 0 when indexing into the header fields.- Overrides:
getHeaderFieldin classURLConnection- Parameters:
key- the name of the header field.- Returns:
- the value of the header field.
-
getHeaderFieldDate
Description copied from class:HttpURLConnectionReturns the date value in milliseconds since01.01.1970, 00:00hcorresponding to the header fieldfield. ThedefaultValuewill be returned if no such field can be found in the response header.- Overrides:
getHeaderFieldDatein classHttpURLConnection- Parameters:
field- the header field name.defaultValue- the default value to use if the specified header field wont be found.- Returns:
- the header field represented in milliseconds since January 1, 1970 GMT.
-
getHeaderFieldInt
Description copied from class:URLConnectionReturns the specified header value as a number. Returns thedefaultValueif no such header field could be found or the value could not be parsed as anInteger.- Overrides:
getHeaderFieldIntin classURLConnection- Parameters:
field- the header field name whose value is needed.defaultValue- the default value if no field has been found.- Returns:
- the value of the specified header field as a number.
-
getHeaderFieldKey
Description copied from class:URLConnectionReturns the name of the header field at the given positionposnornullif there are fewer thanposnfields. The base implementation of this method returns alwaysnull.Some implementations (notably
HttpURLConnection) include a mapping for the null key; in HTTP's case, this maps to the HTTP status line and is treated as being at position 0 when indexing into the header fields.- Overrides:
getHeaderFieldKeyin classURLConnection- Parameters:
position- the position of the header field which has to be returned.- Returns:
- the header field name at the given position.
-
getIfModifiedSince
public long getIfModifiedSince()Description copied from class:URLConnectionReturns the point of time since when the data must be modified to be transmitted. Some protocols transmit data only if it has been modified more recently than a particular time.- Overrides:
getIfModifiedSincein classURLConnection- Returns:
- the time in milliseconds since January 1, 1970 GMT.
- See Also:
URLConnection.ifModifiedSince
-
getInputStream
Description copied from class:URLConnectionReturns anInputStreamfor reading data from the resource pointed by thisURLConnection. It throws an UnknownServiceException by default. This method must be overridden by its subclasses.- Overrides:
getInputStreamin classURLConnection- Returns:
- the InputStream to read data from.
- Throws:
IOException- if no InputStream could be created.
-
getLastModified
public long getLastModified()Description copied from class:URLConnectionReturns the value of the response header fieldlast-modifiedor0if this value is not set.- Overrides:
getLastModifiedin classURLConnection- Returns:
- the value of the
last-modifiedheader field.
-
getOutputStream
Description copied from class:URLConnectionReturns anOutputStreamfor writing data to thisURLConnection. It throws anUnknownServiceExceptionby default. This method must be overridden by its subclasses.- Overrides:
getOutputStreamin classURLConnection- Returns:
- the OutputStream to write data.
- Throws:
IOException- if no OutputStream could be created.
-
getPermission
Description copied from class:HttpURLConnectionReturns the permission object (in this caseSocketPermission) with the host and the port number as the target name and"resolve, connect"as the action list. If the port number of this URL instance is lower than0the port will be set to80.- Overrides:
getPermissionin classHttpURLConnection- Returns:
- the permission object required for this connection.
- Throws:
IOException- if an IO exception occurs during the creation of the permission object.
-
getRequestProperty
Description copied from class:URLConnectionReturns the value of the request header property specified by {code field} ornullif there is no field with this name. The base implementation of this method returns alwaysnull.- Overrides:
getRequestPropertyin classURLConnection- Parameters:
field- the name of the request header property.- Returns:
- the value of the property.
-
getURL
Description copied from class:URLConnectionReturns the URL represented by thisURLConnection.- Overrides:
getURLin classURLConnection- Returns:
- the URL of this connection.
-
getUseCaches
public boolean getUseCaches()Description copied from class:URLConnectionReturns the value of the flag which specifies whether thisURLConnectionallows to use caches.- Overrides:
getUseCachesin classURLConnection- Returns:
trueif using caches is allowed,falseotherwise.
-
setAllowUserInteraction
public void setAllowUserInteraction(boolean newValue)Description copied from class:URLConnectionSetsallowUserInteraction. Unused by Android.- Overrides:
setAllowUserInteractionin classURLConnection
-
setDefaultUseCaches
public void setDefaultUseCaches(boolean newValue)Description copied from class:URLConnectionSets the default value for the flag indicating whether this connection allows to use caches. ExistingURLConnections are unaffected.- Overrides:
setDefaultUseCachesin classURLConnection- Parameters:
newValue- the default value of the flag to be used for new connections.- See Also:
URLConnection.useCaches
-
setDoInput
public void setDoInput(boolean newValue)Description copied from class:URLConnectionSets the flag indicating whether thisURLConnectionallows input. It cannot be set after the connection is established.- Overrides:
setDoInputin classURLConnection- Parameters:
newValue- the new value for the flag to be set.- See Also:
URLConnection.doInput
-
setDoOutput
public void setDoOutput(boolean newValue)Description copied from class:URLConnectionSets the flag indicating whether thisURLConnectionallows output. It cannot be set after the connection is established.- Overrides:
setDoOutputin classURLConnection- Parameters:
newValue- the new value for the flag to be set.- See Also:
URLConnection.doOutput
-
setIfModifiedSince
public void setIfModifiedSince(long newValue)Description copied from class:URLConnectionSets the point of time since when the data must be modified to be transmitted. Some protocols transmit data only if it has been modified more recently than a particular time. The data will be transmitted regardless of its timestamp if this option is set to0.- Overrides:
setIfModifiedSincein classURLConnection- Parameters:
newValue- the time in milliseconds since January 1, 1970 GMT.- See Also:
URLConnection.ifModifiedSince
-
setRequestProperty
Description copied from class:URLConnectionSets the value of the specified request header field. The value will only be used by the currentURLConnectioninstance. This method can only be called before the connection is established.- Overrides:
setRequestPropertyin classURLConnection- Parameters:
field- the request header field to be set.newValue- the new value of the specified property.
-
setUseCaches
public void setUseCaches(boolean newValue)Description copied from class:URLConnectionSets the flag indicating whether this connection allows to use caches or not. This method can only be called prior to the connection establishment.- Overrides:
setUseCachesin classURLConnection- Parameters:
newValue- the value of the flag to be set.- See Also:
URLConnection.useCaches
-
setConnectTimeout
public void setConnectTimeout(int timeoutMillis)Description copied from class:URLConnectionSets the maximum time in milliseconds to wait while connecting. Connecting to a server will fail with aSocketTimeoutExceptionif the timeout elapses before a connection is established. The default value of0causes us to do a blocking connect. This does not mean we will never time out, but it probably means you'll get a TCP timeout after several minutes.Warning: if the hostname resolves to multiple IP addresses, this client will try each in RFC 3484 order. If connecting to each of these addresses fails, multiple timeouts will elapse before the connect attempt throws an exception. Host names that support both IPv6 and IPv4 always have at least 2 IP addresses.
- Overrides:
setConnectTimeoutin classURLConnection
-
getConnectTimeout
public int getConnectTimeout()Description copied from class:URLConnectionReturns the connect timeout in milliseconds. (See {#setConnectTimeout}.)- Overrides:
getConnectTimeoutin classURLConnection
-
setReadTimeout
public void setReadTimeout(int timeoutMillis)Description copied from class:URLConnectionSets the maximum time to wait for an input stream read to complete before giving up. Reading will fail with aSocketTimeoutExceptionif the timeout elapses before data becomes available. The default value of0disables read timeouts; read attempts will block indefinitely.- Overrides:
setReadTimeoutin classURLConnection- Parameters:
timeoutMillis- the read timeout in milliseconds. Non-negative.
-
getReadTimeout
public int getReadTimeout()Description copied from class:URLConnectionReturns the read timeout in milliseconds, or0if reads never timeout.- Overrides:
getReadTimeoutin classURLConnection
-
toString
Description copied from class:URLConnectionReturns the string representation containing the name of this class and the URL.- Overrides:
toStringin classURLConnection- Returns:
- the string representation of this
URLConnectioninstance.
-
setFixedLengthStreamingMode
public void setFixedLengthStreamingMode(int contentLength)Description copied from class:HttpURLConnectionEquivalent tosetFixedLengthStreamingMode((long) contentLength), but available on earlier versions of Android and limited to 2 GiB.- Overrides:
setFixedLengthStreamingModein classHttpURLConnection
-
setChunkedStreamingMode
public void setChunkedStreamingMode(int chunkLength)Description copied from class:HttpURLConnectionStream a request body whose length is not known in advance. Old HTTP/1.0 only servers may not support this mode.When HTTP chunked encoding is used, the stream is divided into chunks, each prefixed with a header containing the chunk's size. Setting a large chunk length requires a large internal buffer, potentially wasting memory. Setting a small chunk length increases the number of bytes that must be transmitted because of the header on every chunk. Most caller should use
0to get the system default.- Overrides:
setChunkedStreamingModein classHttpURLConnection- Parameters:
chunkLength- the length to use, or0for the default chunk length.- See Also:
HttpURLConnection.setFixedLengthStreamingMode(long)
-
setHostnameVerifier
Description copied from class:HttpsURLConnectionSets the hostname verifier for this instance.- Overrides:
setHostnameVerifierin classHttpsURLConnection- Parameters:
hostnameVerifier- the hostname verifier for this instance.
-
getHostnameVerifier
Description copied from class:HttpsURLConnectionReturns the hostname verifier used by this instance.- Overrides:
getHostnameVerifierin classHttpsURLConnection- Returns:
- the hostname verifier used by this instance.
-
setSSLSocketFactory
Description copied from class:HttpsURLConnectionSets the SSL socket factory for this instance.- Overrides:
setSSLSocketFactoryin classHttpsURLConnection- Parameters:
sslSocketFactory- the SSL socket factory to be used by this instance.
-
getSSLSocketFactory
Description copied from class:HttpsURLConnectionReturns the SSL socket factory used by this instance.- Overrides:
getSSLSocketFactoryin classHttpsURLConnection- Returns:
- the SSL socket factory used by this instance.
-