public class

HttpsURLConnectionImpl

extends HttpsURLConnection
java.lang.Object
   ↳ java.net.URLConnection
     ↳ java.net.HttpURLConnection
       ↳ javax.net.ssl.HttpsURLConnection
         ↳ sun.net.www.protocol.https.HttpsURLConnectionImpl

Class Overview

A class to represent an HTTP connection to a remote object. Ideally, this class should subclass and inherit the http handler implementation, but it can't do so because that class have the wrong Java Type. Thus it uses the delegate (aka, the Adapter/Wrapper design pattern) to reuse code from the http handler. Since it would use a delegate to access sun.net.www.protocol.http.HttpURLConnection functionalities, it needs to implement all public methods in it's super class and all the way to Object.

Summary

[Expand]
Inherited Constants
From class java.net.HttpURLConnection
Fields
protected DelegateHttpsURLConnection delegate
[Expand]
Inherited Fields
From class javax.net.ssl.HttpsURLConnection
From class java.net.HttpURLConnection
From class java.net.URLConnection
Protected Constructors
HttpsURLConnectionImpl(URL u)
Public Methods
void addRequestProperty(String key, String value)
Adds a general request property specified by a key-value pair.
void connect()
Implements the HTTP protocol handler's "connect" method, establishing an SSL connection to the server as necessary.
void disconnect()
Disconnect from the server.
boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
boolean getAllowUserInteraction()
Returns the value of the allowUserInteraction field for this object.
String getCipherSuite()
Returns the cipher suite in use on this connection.
int getConnectTimeout()
Returns setting for connect timeout.
Object getContent()
Retrieves the contents of this URL connection.
Object getContent(Class[] classes)
Retrieves the contents of this URL connection.
String getContentEncoding()
Returns the value of the content-encoding header field.
int getContentLength()
Returns the value of the content-length header field.
String getContentType()
Returns the value of the content-type header field.
long getDate()
Returns the value of the date header field.
boolean getDefaultUseCaches()
Returns the default value of a URLConnection's useCaches flag.
boolean getDoInput()
Returns the value of this URLConnection's doInput flag.
boolean getDoOutput()
Returns the value of this URLConnection's doOutput flag.
InputStream getErrorStream()
Returns the error stream if the connection failed but the server sent useful data nonetheless.
long getExpiration()
Returns the value of the expires header field.
String getHeaderField(String name)
Gets a header field by name.
String getHeaderField(int n)
Gets a header field by index.
long getHeaderFieldDate(String name, long Default)
Returns the value of the named field parsed as date.
int getHeaderFieldInt(String name, int Default)
Returns the value of the named field parsed as a number.
String getHeaderFieldKey(int n)
Gets a header field by index.
Map<StringList<String>> getHeaderFields()
Returns an unmodifiable Map of the header fields.
long getIfModifiedSince()
Returns the value of this object's ifModifiedSince field.
synchronized InputStream getInputStream()
Returns an input stream that reads from this open connection.
boolean getInstanceFollowRedirects()
Returns the value of this HttpURLConnection's instanceFollowRedirects field.
long getLastModified()
Returns the value of the last-modified header field.
Certificate[] getLocalCertificates()
Returns the certificate chain the client sent to the server, or null if the client did not authenticate.
Principal getLocalPrincipal()
Returns the principal the client sent to the server, or null if the client did not authenticate.
synchronized OutputStream getOutputStream()
Returns an output stream that writes to this connection.
Principal getPeerPrincipal()
Returns the principal with which the server authenticated itself, or throw a SSLPeerUnverifiedException if the server did not authenticate.
Permission getPermission()
Returns a permission object representing the permission necessary to make the connection represented by this object.
int getReadTimeout()
Returns setting for read timeout.
String getRequestMethod()
Get the request method.
Map<StringList<String>> getRequestProperties()
Returns an unmodifiable Map of general request properties for this connection.
String getRequestProperty(String key)
Returns the value of the named general request property for this connection.
int getResponseCode()
Overwrite super class method
String getResponseMessage()
Gets the HTTP response message, if any, returned along with the response code from a server.
X509Certificate[] getServerCertificateChain()
Returns the server's X.509 certificate chain, or null if the server did not authenticate.
Certificate[] getServerCertificates()
Returns the server's certificate chain, or throws SSLPeerUnverified Exception if the server did not authenticate.
URL getURL()
Returns the value of this URLConnection's URL field.
boolean getUseCaches()
Returns the value of this URLConnection's useCaches field.
int hashCode()
Returns a hash code value for the object.
void setAllowUserInteraction(boolean allowuserinteraction)
Set the value of the allowUserInteraction field of this URLConnection.
void setChunkedStreamingMode(int chunklen)
This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance.
void setConnectTimeout(int timeout)
Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.
void setDefaultUseCaches(boolean defaultusecaches)
Sets the default value of the useCaches field to the specified value.
void setDoInput(boolean doinput)
Sets the value of the doInput field for this URLConnection to the specified value.
void setDoOutput(boolean dooutput)
Sets the value of the doOutput field for this URLConnection to the specified value.
void setFixedLengthStreamingMode(int contentLength)
This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.
void setIfModifiedSince(long ifmodifiedsince)
Sets the value of the ifModifiedSince field of this URLConnection to the specified value.
void setInstanceFollowRedirects(boolean shouldFollow)
Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this HttpURLConnection instance.
void setReadTimeout(int timeout)
Sets the read timeout to a specified timeout, in milliseconds.
void setRequestMethod(String method)
Set the method for the URL request, one of:
  • GET
  • POST
  • HEAD
  • OPTIONS
  • PUT
  • DELETE
  • TRACE
are legal, subject to protocol restrictions.
void setRequestProperty(String key, String value)
Sets request property.
void setUseCaches(boolean usecaches)
Sets the value of the useCaches field of this URLConnection to the specified value.
String toString()
Returns a String representation of this URL connection.
boolean usingProxy()
Indicates if the connection is going through a proxy.
Protected Methods
void finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
boolean isConnected()
Used by subclass to access "connected" variable.
void setConnected(boolean conn)
Used by subclass to access "connected" variable.
void setNewClient(URL url, boolean useCache)
Obtain a HttpClient object.
void setNewClient(URL url)
Create a new HttpClient object, bypassing the cache of HTTP client objects/connections.
void setProxiedClient(URL url, String proxyHost, int proxyPort)
Create a new HttpClient object, set up so that it uses per-instance proxying to the given HTTP proxy.
void setProxiedClient(URL url, String proxyHost, int proxyPort, boolean useCache)
Obtain a HttpClient object, set up so that it uses per-instance proxying to the given HTTP proxy.
[Expand]
Inherited Methods
From class javax.net.ssl.HttpsURLConnection
From class java.net.HttpURLConnection
From class java.net.URLConnection
From class java.lang.Object

Fields

protected DelegateHttpsURLConnection delegate

Protected Constructors

protected HttpsURLConnectionImpl (URL u)

Throws
IOException

Public Methods

public void addRequestProperty (String key, String value)

Adds a general request property specified by a key-value pair. This method will not overwrite existing values associated with the same key.

Parameters
key the keyword by which the request is known (e.g., "accept").
value the value associated with it.
See Also
  • #getRequestProperties(java.lang.String)

public void connect ()

Implements the HTTP protocol handler's "connect" method, establishing an SSL connection to the server as necessary.

Throws
IOException

public void disconnect ()

Disconnect from the server.

public boolean equals (Object obj)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
obj the reference object with which to compare.
Returns
  • true if this object is the same as the obj argument; false otherwise.

public boolean getAllowUserInteraction ()

Returns the value of the allowUserInteraction field for this object.

Returns
  • the value of the allowUserInteraction field for this object.

public String getCipherSuite ()

Returns the cipher suite in use on this connection.

Returns
  • the cipher suite

public int getConnectTimeout ()

Returns setting for connect timeout.

0 return implies that the option is disabled (i.e., timeout of infinity).

Returns
  • an int that indicates the connect timeout value in milliseconds

public Object getContent ()

Retrieves the contents of this URL connection.

This method first determines the content type of the object by calling the getContentType method. If this is the first time that the application has seen that specific content type, a content handler for that content type is created:

  1. If the application has set up a content handler factory instance using the setContentHandlerFactory method, the createContentHandler method of that instance is called with the content type as an argument; the result is a content handler for that content type.
  2. If no content handler factory has yet been set up, or if the factory's createContentHandler method returns null, then the application loads the class named:
             sun.net.www.content.<contentType>
         
    where <contentType> is formed by taking the content-type string, replacing all slash characters with a period ('.'), and all other non-alphanumeric characters with the underscore character '_'. The alphanumeric characters are specifically the 26 uppercase ASCII letters 'A' through 'Z', the 26 lowercase ASCII letters 'a' through 'z', and the 10 ASCII digits '0' through '9'. If the specified class does not exist, or is not a subclass of ContentHandler, then an UnknownServiceException is thrown.

Returns
  • the object fetched. The instanceof operator should be used to determine the specific kind of object returned.
Throws
IOException

public Object getContent (Class[] classes)

Retrieves the contents of this URL connection.

Parameters
classes the Class array indicating the requested types
Returns
  • the object fetched that is the first match of the type specified in the classes array. null if none of the requested types are supported. The instanceof operator should be used to determine the specific kind of object returned.
Throws
IOException

public String getContentEncoding ()

Returns the value of the content-encoding header field.

Returns
  • the content encoding of the resource that the URL references, or null if not known.

public int getContentLength ()

Returns the value of the content-length header field.

Returns
  • the content length of the resource that this connection's URL references, or -1 if the content length is not known.

public String getContentType ()

Returns the value of the content-type header field.

Returns
  • the content type of the resource that the URL references, or null if not known.

public long getDate ()

Returns the value of the date header field.

Returns
  • the sending date of the resource that the URL references, or 0 if not known. The value returned is the number of milliseconds since January 1, 1970 GMT.

public boolean getDefaultUseCaches ()

Returns the default value of a URLConnection's useCaches flag.

Ths default is "sticky", being a part of the static state of all URLConnections. This flag applies to the next, and all following URLConnections that are created.

Returns
  • the default value of a URLConnection's useCaches flag.

public boolean getDoInput ()

Returns the value of this URLConnection's doInput flag.

Returns
  • the value of this URLConnection's doInput flag.

public boolean getDoOutput ()

Returns the value of this URLConnection's doOutput flag.

Returns
  • the value of this URLConnection's doOutput flag.

public InputStream getErrorStream ()

Returns the error stream if the connection failed but the server sent useful data nonetheless. The typical example is when an HTTP server responds with a 404, which will cause a FileNotFoundException to be thrown in connect, but the server sent an HTML help page with suggestions as to what to do.

This method will not cause a connection to be initiated. If the connection was not connected, or if the server did not have an error while connecting or if the server had an error but no error data was sent, this method will return null. This is the default.

Returns
  • an error stream if any, null if there have been no errors, the connection is not connected or the server sent no useful data.

public long getExpiration ()

Returns the value of the expires header field.

Returns
  • the expiration date of the resource that this URL references, or 0 if not known. The value is the number of milliseconds since January 1, 1970 GMT.

public String getHeaderField (String name)

Gets a header field by name. Returns null if not known.

Parameters
name the name of the header field
Returns
  • the value of the named header field, or null if there is no such field in the header.

public String getHeaderField (int n)

Gets a header field by index. Returns null if not known.

Parameters
n the index of the header field
Returns
  • the value of the nth header field, or null if the value does not exist.

public long getHeaderFieldDate (String name, long Default)

Returns the value of the named field parsed as date. The result is the number of milliseconds since January 1, 1970 GMT represented by the named field.

This form of getHeaderField exists because some connection types (e.g., http-ng) have pre-parsed headers. Classes for that connection type can override this method and short-circuit the parsing.

Parameters
name the name of the header field.
Default a default value.
Returns
  • the value of the field, parsed as a date. The value of the Default argument is returned if the field is missing or malformed.

public int getHeaderFieldInt (String name, int Default)

Returns the value of the named field parsed as a number.

This form of getHeaderField exists because some connection types (e.g., http-ng) have pre-parsed headers. Classes for that connection type can override this method and short-circuit the parsing.

Parameters
name the name of the header field.
Default the default value.
Returns
  • the value of the named field, parsed as an integer. The Default value is returned if the field is missing or malformed.

public String getHeaderFieldKey (int n)

Gets a header field by index. Returns null if not known.

Parameters
n the index of the header field
Returns
  • the key for the nth header field, or null if the key does not exist.

public Map<StringList<String>> getHeaderFields ()

Returns an unmodifiable Map of the header fields. The Map keys are Strings that represent the response-header field names. Each Map value is an unmodifiable List of Strings that represents the corresponding field values.

Returns
  • a Map of header fields

public long getIfModifiedSince ()

Returns the value of this object's ifModifiedSince field.

Returns
  • the value of this object's ifModifiedSince field.

public synchronized InputStream getInputStream ()

Returns an input stream that reads from this open connection. A SocketTimeoutException can be thrown when reading from the returned input stream if the read timeout expires before data is available for read.

Returns
  • an input stream that reads from this open connection.
Throws
IOException

public boolean getInstanceFollowRedirects ()

Returns the value of this HttpURLConnection's instanceFollowRedirects field.

Returns
  • the value of this HttpURLConnection's instanceFollowRedirects field.

public long getLastModified ()

Returns the value of the last-modified header field. The result is the number of milliseconds since January 1, 1970 GMT.

Returns
  • the date the resource referenced by this URLConnection was last modified, or 0 if not known.

public Certificate[] getLocalCertificates ()

Returns the certificate chain the client sent to the server, or null if the client did not authenticate.

Returns
  • an ordered array of certificates, with the client's own certificate first followed by any certificate authorities. If no certificates were sent, then null is returned.

public Principal getLocalPrincipal ()

Returns the principal the client sent to the server, or null if the client did not authenticate.

Returns
  • the principal sent to the server. Returns an X500Principal of the end-entity certificate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites. If no principal was sent, then null is returned.

public synchronized OutputStream getOutputStream ()

Returns an output stream that writes to this connection.

Returns
  • an output stream that writes to this connection.
Throws
IOException

public Principal getPeerPrincipal ()

Returns the principal with which the server authenticated itself, or throw a SSLPeerUnverifiedException if the server did not authenticate.

Returns
  • the server's principal. Returns an X500Principal of the end-entity certiticate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites.

public Permission getPermission ()

Returns a permission object representing the permission necessary to make the connection represented by this object. This method returns null if no permission is required to make the connection. By default, this method returns java.security.AllPermission. Subclasses should override this method and return the permission that best represents the permission required to make a a connection to the URL. For example, a URLConnection representing a file: URL would return a java.io.FilePermission object.

The permission returned may dependent upon the state of the connection. For example, the permission before connecting may be different from that after connecting. For example, an HTTP sever, say foo.com, may redirect the connection to a different host, say bar.com. Before connecting the permission returned by the connection will represent the permission needed to connect to foo.com, while the permission returned after connecting will be to bar.com.

Permissions are generally used for two purposes: to protect caches of objects obtained through URLConnections, and to check the right of a recipient to learn about a particular URL. In the first case, the permission should be obtained after the object has been obtained. For example, in an HTTP connection, this will represent the permission to connect to the host from which the data was ultimately fetched. In the second case, the permission should be obtained and tested before connecting.

Returns
  • the permission object representing the permission necessary to make the connection represented by this URLConnection.
Throws
IOException

public int getReadTimeout ()

Returns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).

Returns
  • an int that indicates the read timeout value in milliseconds

public String getRequestMethod ()

Get the request method.

Returns
  • the HTTP request method

public Map<StringList<String>> getRequestProperties ()

Returns an unmodifiable Map of general request properties for this connection. The Map keys are Strings that represent the request-header field names. Each Map value is a unmodifiable List of Strings that represents the corresponding field values.

Returns
  • a Map of the general request properties for this connection.
Throws
IllegalStateException if already connected

public String getRequestProperty (String key)

Returns the value of the named general request property for this connection.

Parameters
key the keyword by which the request is known (e.g., "accept").
Returns
  • the value of the named general request property for this connection. If key is null, then null is returned.

public int getResponseCode ()

Overwrite super class method

Returns
  • the HTTP Status-Code, or -1
Throws
IOException

public String getResponseMessage ()

Gets the HTTP response message, if any, returned along with the response code from a server. From responses like:

 HTTP/1.0 200 OK
 HTTP/1.0 404 Not Found
 
Extracts the Strings "OK" and "Not Found" respectively. Returns null if none could be discerned from the responses (the result was not valid HTTP).

Returns
  • the HTTP response message, or null
Throws
IOException

public X509Certificate[] getServerCertificateChain ()

Returns the server's X.509 certificate chain, or null if the server did not authenticate. NOTE: This method is not necessary for the version of this class implementing javax.net.ssl.HttpsURLConnection, but provided for compatibility with the com.sun.net.ssl.HttpsURLConnection version.

public Certificate[] getServerCertificates ()

Returns the server's certificate chain, or throws SSLPeerUnverified Exception if the server did not authenticate.

Returns
  • an ordered array of server certificates, with the peer's own certificate first followed by any certificate authorities.

public URL getURL ()

Returns the value of this URLConnection's URL field.

Returns
  • the value of this URLConnection's URL field.

public boolean getUseCaches ()

Returns the value of this URLConnection's useCaches field.

Returns
  • the value of this URLConnection's useCaches field.

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Returns
  • a hash code value for this object.

public void setAllowUserInteraction (boolean allowuserinteraction)

Set the value of the allowUserInteraction field of this URLConnection.

Parameters
allowuserinteraction the new value.

public void setChunkedStreamingMode (int chunklen)

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is not known in advance. In this mode, chunked transfer encoding is used to send the request body. Note, not all HTTP servers support this mode.

When output streaming is enabled, authentication and redirection cannot be handled automatically. A HttpRetryException will be thrown when reading the response if authentication or redirection are required. This exception can be queried for the details of the error.

This method must be called before the URLConnection is connected.

Parameters
chunklen The number of bytes to write in each chunk. If chunklen is less than or equal to zero, a default value will be used.

public void setConnectTimeout (int timeout)

Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection. If the timeout expires before the connection can be established, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.

Some non-standard implmentation of this method may ignore the specified timeout. To see the connect timeout set, please call getConnectTimeout().

Parameters
timeout an int that specifies the connect timeout value in milliseconds

public void setDefaultUseCaches (boolean defaultusecaches)

Sets the default value of the useCaches field to the specified value.

Parameters
defaultusecaches the new value.

public void setDoInput (boolean doinput)

Sets the value of the doInput field for this URLConnection to the specified value.

A URL connection can be used for input and/or output. Set the DoInput flag to true if you intend to use the URL connection for input, false if not. The default is true.

Parameters
doinput the new value.

public void setDoOutput (boolean dooutput)

Sets the value of the doOutput field for this URLConnection to the specified value.

A URL connection can be used for input and/or output. Set the DoOutput flag to true if you intend to use the URL connection for output, false if not. The default is false.

Parameters
dooutput the new value.

public void setFixedLengthStreamingMode (int contentLength)

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.

An exception will be thrown if the application attempts to write more data than the indicated content-length, or if the application closes the OutputStream before writing the indicated amount.

When output streaming is enabled, authentication and redirection cannot be handled automatically. A HttpRetryException will be thrown when reading the response if authentication or redirection are required. This exception can be queried for the details of the error.

This method must be called before the URLConnection is connected.

Parameters
contentLength The number of bytes which will be written to the OutputStream.

public void setIfModifiedSince (long ifmodifiedsince)

Sets the value of the ifModifiedSince field of this URLConnection to the specified value.

Parameters
ifmodifiedsince the new value.

public void setInstanceFollowRedirects (boolean shouldFollow)

Sets whether HTTP redirects (requests with response code 3xx) should be automatically followed by this HttpURLConnection instance.

The default value comes from followRedirects, which defaults to true.

Parameters
shouldFollow a boolean indicating whether or not to follow HTTP redirects.

public void setReadTimeout (int timeout)

Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.

Some non-standard implementation of this method ignores the specified timeout. To see the read timeout set, please call getReadTimeout().

Parameters
timeout an int that specifies the timeout value to be used in milliseconds

public void setRequestMethod (String method)

Set the method for the URL request, one of:

  • GET
  • POST
  • HEAD
  • OPTIONS
  • PUT
  • DELETE
  • TRACE
are legal, subject to protocol restrictions. The default method is GET.

Parameters
method the HTTP method

public void setRequestProperty (String key, String value)

Sets request property. If a property with the key already exists, overwrite its value with the new value.

Parameters
key the keyword by which the request is known (e.g., "accept").
value the value to be set

public void setUseCaches (boolean usecaches)

Sets the value of the useCaches field of this URLConnection to the specified value.

Some protocols do caching of documents. Occasionally, it is important to be able to "tunnel through" and ignore the caches (e.g., the "reload" button in a browser). If the UseCaches flag on a connection is true, the connection is allowed to use whatever caches it can. If false, caches are to be ignored. The default value comes from DefaultUseCaches, which defaults to true.

Parameters
usecaches a boolean indicating whether or not to allow caching

public String toString ()

Returns a String representation of this URL connection.

Returns
  • a string representation of this URLConnection.

public boolean usingProxy ()

Indicates if the connection is going through a proxy.

Returns
  • a boolean indicating if the connection is using a proxy.

Protected Methods

protected void finalize ()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Throws
Throwable

protected boolean isConnected ()

Used by subclass to access "connected" variable. Since we are delegating the actual implementation to "delegate", we need to delegate the access of "connected" as well.

protected void setConnected (boolean conn)

Used by subclass to access "connected" variable. Since we are delegating the actual implementation to "delegate", we need to delegate the access of "connected" as well.

protected void setNewClient (URL url, boolean useCache)

Obtain a HttpClient object. Use the cached copy if specified.

Parameters
url the URL being accessed
useCache whether the cached connection should be used if present
Throws
IOException

protected void setNewClient (URL url)

Create a new HttpClient object, bypassing the cache of HTTP client objects/connections.

Parameters
url the URL being accessed
Throws
IOException

protected void setProxiedClient (URL url, String proxyHost, int proxyPort)

Create a new HttpClient object, set up so that it uses per-instance proxying to the given HTTP proxy. This bypasses the cache of HTTP client objects/connections.

Parameters
url the URL being accessed
proxyHost the proxy host to use
proxyPort the proxy port to use
Throws
IOException

protected void setProxiedClient (URL url, String proxyHost, int proxyPort, boolean useCache)

Obtain a HttpClient object, set up so that it uses per-instance proxying to the given HTTP proxy. Use the cached copy of HTTP client objects/connections if specified.

Parameters
url the URL being accessed
proxyHost the proxy host to use
proxyPort the proxy port to use
useCache whether the cached connection should be used if present
Throws
IOException