APIdia Launch Partner
Top Description Fields Constructors Methods
sun.net.www.protocol.https

public Class HttpsURLConnectionImpl

extends HttpsURLConnection
Class Inheritance
Imports
java.net.URL, .Proxy, .ProtocolException, .MalformedURLException, .Authenticator, java.io.*, javax.net.ssl.*, java.security.Permission, .Principal, java.util.Map, .List, .Optional, sun.net.util.IPAddressUtil

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.

Field Summary

Modifier and TypeField and Description
private final DelegateHttpsURLConnection
Inherited from javax.net.ssl.HttpsURLConnection:
hostnameVerifier

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
addRequestProperty(String
the keyword by which the request is known (e.g., "accept").
key
,
String
the value associated with it.
value
)

Overrides java.net.URLConnection.addRequestProperty.

Adds a general request property specified by a key-value pair.

pack-priv static URL
public void
connect()

Implements abstract java.net.URLConnection.connect.

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

public void
disconnect()

Implements abstract java.net.HttpURLConnection.disconnect.

Disconnect from the server.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

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

public boolean
getAllowUserInteraction()

Overrides java.net.URLConnection.getAllowUserInteraction.

Returns the value of the allowUserInteraction field for this object.

public String
getCipherSuite()

Implements abstract javax.net.ssl.HttpsURLConnection.getCipherSuite.

Returns the cipher suite in use on this connection.

public int
getConnectTimeout()

Overrides java.net.URLConnection.getConnectTimeout.

Returns setting for connect timeout.

public Object
getContent()

Overrides java.net.URLConnection.getContent.

Retrieves the contents of this URL connection.

public Object
getContent(Class<T>[] classes)

Overrides java.net.URLConnection.getContent.

Retrieves the contents of this URL connection.

public String
getContentEncoding()

Overrides java.net.URLConnection.getContentEncoding.

Returns the value of the content-encoding header field.

public int
getContentLength()

Overrides java.net.URLConnection.getContentLength.

Returns the value of the content-length header field.

public long
getContentLengthLong()

Overrides java.net.URLConnection.getContentLengthLong.

Returns the value of the content-length header field as a long.

public String
getContentType()

Overrides java.net.URLConnection.getContentType.

Returns the value of the content-type header field.

public long
getDate()

Overrides java.net.URLConnection.getDate.

Returns the value of the date header field.

public boolean
getDefaultUseCaches()

Overrides java.net.URLConnection.getDefaultUseCaches.

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

public boolean
getDoInput()

Overrides java.net.URLConnection.getDoInput.

Returns the value of this URLConnection's doInput flag.

public boolean
getDoOutput()

Overrides java.net.URLConnection.getDoOutput.

Returns the value of this URLConnection's doOutput flag.

public InputStream
getErrorStream()

Overrides java.net.HttpURLConnection.getErrorStream.

Returns the error stream if the connection failed but the server sent useful data nonetheless.

public long
getExpiration()

Overrides java.net.URLConnection.getExpiration.

Returns the value of the expires header field.

public String
getHeaderField(String
the name of the header field
name
)

Overrides java.net.URLConnection.getHeaderField.

Gets a header field by name.

public String
getHeaderField(int
the index of the header field
n
)

Overrides java.net.HttpURLConnection.getHeaderField.

Gets a header field by index.

public long
getHeaderFieldDate(String name, long defaultValue)

Overrides java.net.HttpURLConnection.getHeaderFieldDate.

Returns the value of the named field parsed as date.

public int
getHeaderFieldInt(String name, int defaultValue)

Overrides java.net.URLConnection.getHeaderFieldInt.

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

public String
getHeaderFieldKey(int
the index of the header field
n
)

Overrides java.net.HttpURLConnection.getHeaderFieldKey.

Gets a header field by index.

public long
getHeaderFieldLong(String name, long defaultValue)

Overrides java.net.URLConnection.getHeaderFieldLong.

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

public Map<String, List<String>>

Returns:

a Map of header fields
getHeaderFields
()

Overrides java.net.URLConnection.getHeaderFields.

Returns an unmodifiable Map of the header fields.

public long
getIfModifiedSince()

Overrides java.net.URLConnection.getIfModifiedSince.

Returns the value of this object's ifModifiedSince field.

public InputStream
getInputStream()

Overrides java.net.URLConnection.getInputStream.

Returns an input stream that reads from this open connection.

public boolean
getInstanceFollowRedirects()

Overrides java.net.HttpURLConnection.getInstanceFollowRedirects.

Returns the value of this HttpURLConnection's instanceFollowRedirects field.

public long
getLastModified()

Overrides java.net.URLConnection.getLastModified.

Returns the value of the last-modified header field.

public Certificate[]
getLocalCertificates()

Implements abstract javax.net.ssl.HttpsURLConnection.getLocalCertificates.

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

public Principal
getLocalPrincipal()

Overrides javax.net.ssl.HttpsURLConnection.getLocalPrincipal.

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

public OutputStream
getOutputStream()

Overrides java.net.URLConnection.getOutputStream.

Returns an output stream that writes to this connection.

public Principal
getPeerPrincipal()

Overrides javax.net.ssl.HttpsURLConnection.getPeerPrincipal.

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

public Permission
getPermission()

Overrides java.net.HttpURLConnection.getPermission.

Deprecated for removal since 25.

Returns a SocketPermission object representing the permission necessary to connect to the destination host and port.

public int
getReadTimeout()

Overrides java.net.URLConnection.getReadTimeout.

Returns setting for read timeout.

public String
public Map<String, List<String>>

Returns:

a Map of the general request properties for this connection.
getRequestProperties
()

Overrides java.net.URLConnection.getRequestProperties.

Returns an unmodifiable Map of general request properties for this connection.

public String
getRequestProperty(String key)

Overrides java.net.URLConnection.getRequestProperty.

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

public int
getResponseCode()

Overrides java.net.HttpURLConnection.getResponseCode.

Overwrite super class method

public String
getResponseMessage()

Overrides java.net.HttpURLConnection.getResponseMessage.

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

public Certificate[]
getServerCertificates()

Implements abstract javax.net.ssl.HttpsURLConnection.getServerCertificates.

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

public Optional<SSLSession>
getSSLSession()

Overrides javax.net.ssl.HttpsURLConnection.getSSLSession.

Returns an Optional containing the SSLSession in use on this connection.

public URL
getURL()

Overrides java.net.URLConnection.getURL.

Returns the value of this URLConnection's URL field.

public boolean
getUseCaches()

Overrides java.net.URLConnection.getUseCaches.

Returns the value of this URLConnection's useCaches field.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

protected boolean
isConnected()

Used by subclass to access "connected" variable.

public void
setAllowUserInteraction(boolean allowuserinteraction)

Overrides java.net.URLConnection.setAllowUserInteraction.

Set the value of the allowUserInteraction field of this URLConnection.

public void
setAuthenticator(Authenticator auth)

Overrides java.net.HttpURLConnection.setAuthenticator.

Supplies an Authenticator to be used when authentication is requested through the HTTP protocol for this HttpURLConnection.

public void
setChunkedStreamingMode(int chunklen)

Overrides java.net.HttpURLConnection.setChunkedStreamingMode.

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

protected void
setConnected(boolean conn)

Used by subclass to access "connected" variable.

public void
setConnectTimeout(int timeout)

Overrides java.net.URLConnection.setConnectTimeout.

Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.

public void
setDefaultUseCaches(boolean defaultusecaches)

Overrides java.net.URLConnection.setDefaultUseCaches.

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

public void
setDoInput(boolean doinput)

Overrides java.net.URLConnection.setDoInput.

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

public void
setDoOutput(boolean dooutput)

Overrides java.net.URLConnection.setDoOutput.

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

public void
setFixedLengthStreamingMode(int contentLength)

Overrides java.net.HttpURLConnection.setFixedLengthStreamingMode.

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

public void
setFixedLengthStreamingMode(long contentLength)

Overrides java.net.HttpURLConnection.setFixedLengthStreamingMode.

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

public void
setIfModifiedSince(long ifmodifiedsince)

Overrides java.net.URLConnection.setIfModifiedSince.

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

public void
setInstanceFollowRedirects(boolean shouldFollow)

Overrides java.net.HttpURLConnection.setInstanceFollowRedirects.

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

protected void
setNewClient(URL
the URL being accessed
url
)

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

protected void
setNewClient(URL
the URL being accessed
url
,
boolean
whether the cached connection should be used if present
useCache
)

Obtain a HttpClient object.

protected void
setProxiedClient(URL
the URL being accessed
url
,
String
the proxy host to use
proxyHost
,
int
the proxy port to use
proxyPort
)

Create a new HttpClient object, set up so that it uses per-instance proxying to the given HTTP proxy.

protected void
setProxiedClient(URL
the URL being accessed
url
,
String
the proxy host to use
proxyHost
,
int
the proxy port to use
proxyPort
,
boolean
whether the cached connection should be used if present
useCache
)

Obtain a HttpClient object, set up so that it uses per-instance proxying to the given HTTP proxy.

public void
setReadTimeout(int timeout)

Overrides java.net.URLConnection.setReadTimeout.

Sets the read timeout to a specified timeout, in milliseconds.

public void
setRequestMethod(String method)

Overrides java.net.HttpURLConnection.setRequestMethod.

Set the method for the URL request, one of:

  • GET
  • POST
  • HEAD
  • OPTIONS
  • PUT
  • DELETE
  • TRACE
public void
setRequestProperty(String key, String
the value to be set
value
)

Overrides java.net.URLConnection.setRequestProperty.

Sets request property.

public void
setUseCaches(boolean usecaches)

Overrides java.net.URLConnection.setUseCaches.

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

public String
toString()

Overrides java.net.URLConnection.toString.

Returns a String representation of this URL connection.

public boolean
usingProxy()

Implements abstract java.net.HttpURLConnection.usingProxy.

Indicates if the connection is going through a proxy.

Inherited from javax.net.ssl.HttpsURLConnection:
getDefaultHostnameVerifiergetDefaultSSLSocketFactorygetHostnameVerifiergetSSLSocketFactorysetDefaultHostnameVerifiersetDefaultSSLSocketFactorysetHostnameVerifiersetSSLSocketFactory

Field Detail

delegateback to summary
private final DelegateHttpsURLConnection delegate

Constructor Detail

HttpsURLConnectionImplback to summary
pack-priv HttpsURLConnectionImpl(URL u, Handler handler) throws IOException
HttpsURLConnectionImplback to summary
pack-priv HttpsURLConnectionImpl(URL u, Proxy p, Handler handler) throws IOException

Method Detail

addRequestPropertyback to summary
public void addRequestProperty(String key, String value)

Overrides java.net.URLConnection.addRequestProperty.

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:String

the keyword by which the request is known (e.g., "accept").

value:String

the value associated with it.

Since
1.4
See Also
getRequestProperty(java.lang.String)
checkURLback to summary
pack-priv static URL checkURL(URL u) throws IOException
connectback to summary
public void connect() throws IOException

Implements abstract java.net.URLConnection.connect.

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

Exceptions
IOException:

Doc from java.net.URLConnection.connect.

if an I/O error occurs while opening the connection.

disconnectback to summary
public void disconnect()

Implements abstract java.net.HttpURLConnection.disconnect.

Disconnect from the server.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

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.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

getAllowUserInteractionback to summary
public boolean getAllowUserInteraction()

Overrides java.net.URLConnection.getAllowUserInteraction.

Doc from java.net.URLConnection.getAllowUserInteraction.

Returns the value of the allowUserInteraction field for this object.

getCipherSuiteback to summary
public String getCipherSuite()

Implements abstract javax.net.ssl.HttpsURLConnection.getCipherSuite.

Returns the cipher suite in use on this connection.

getConnectTimeoutback to summary
public int getConnectTimeout()

Overrides java.net.URLConnection.getConnectTimeout.

Doc from java.net.URLConnection.getConnectTimeout.

Returns setting for connect timeout.

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

getContentback to summary
public Object getContent() throws IOException

Overrides java.net.URLConnection.getContent.

Doc from java.net.URLConnection.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.

This is done as follows:

  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 ContentHandlerFactory has yet been set up, or if the factory's createContentHandler method returns null, then the ServiceLoader mechanism is used to locate ContentHandlerFactory implementations using the system class loader. The order that factories are located is implementation specific, and an implementation is free to cache the located factories. A ServiceConfigurationError, Error or RuntimeException thrown from the createContentHandler, if encountered, will be propagated to the calling thread. The createContentHandler method of each factory, if instantiated, is invoked, with the content type, until a factory returns non-null, or all factories have been exhausted.
  3. Failing that, this method tries to load a content handler class as defined by ContentHandler. If the class does not exist, or is not a subclass of ContentHandler, then an UnknownServiceException is thrown.
Exceptions
IOException:
if an I/O error occurs while getting the content.
getContentback to summary
public Object getContent(Class<T>[] classes) throws IOException

Overrides java.net.URLConnection.getContent.

Doc from java.net.URLConnection.getContent.

Retrieves the contents of this URL connection.

Annotations
@SuppressWarnings:rawtypes
Exceptions
IOException:
if an I/O error occurs while getting the content.
getContentEncodingback to summary
public String getContentEncoding()

Overrides java.net.URLConnection.getContentEncoding.

Doc from java.net.URLConnection.getContentEncoding.

Returns the value of the content-encoding header field.

getContentLengthback to summary
public int getContentLength()

Overrides java.net.URLConnection.getContentLength.

Doc from java.net.URLConnection.getContentLength.

Returns the value of the content-length header field.

Note

getContentLengthLong() should be preferred over this method, since it returns a long instead and is therefore more portable.

getContentLengthLongback to summary
public long getContentLengthLong()

Overrides java.net.URLConnection.getContentLengthLong.

Doc from java.net.URLConnection.getContentLengthLong.

Returns the value of the content-length header field as a long.

getContentTypeback to summary
public String getContentType()

Overrides java.net.URLConnection.getContentType.

Doc from java.net.URLConnection.getContentType.

Returns the value of the content-type header field.

getDateback to summary
public long getDate()

Overrides java.net.URLConnection.getDate.

Doc from java.net.URLConnection.getDate.

Returns the value of the date header field.

getDefaultUseCachesback to summary
public boolean getDefaultUseCaches()

Overrides java.net.URLConnection.getDefaultUseCaches.

Doc from java.net.URLConnection.getDefaultUseCaches.

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

This 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. This default value can be over-ridden per protocol using setDefaultUseCaches(String, boolean)

getDoInputback to summary
public boolean getDoInput()

Overrides java.net.URLConnection.getDoInput.

Doc from java.net.URLConnection.getDoInput.

Returns the value of this URLConnection's doInput flag.

getDoOutputback to summary
public boolean getDoOutput()

Overrides java.net.URLConnection.getDoOutput.

Doc from java.net.URLConnection.getDoOutput.

Returns the value of this URLConnection's doOutput flag.

getErrorStreamback to summary
public InputStream getErrorStream()

Overrides java.net.HttpURLConnection.getErrorStream.

Doc from java.net.HttpURLConnection.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.

getExpirationback to summary
public long getExpiration()

Overrides java.net.URLConnection.getExpiration.

Doc from java.net.URLConnection.getExpiration.

Returns the value of the expires header field.

getHeaderFieldback to summary
public String getHeaderField(String name)

Overrides java.net.URLConnection.getHeaderField.

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

Parameters
name:String

the name of the header field

getHeaderFieldback to summary
public String getHeaderField(int n)

Overrides java.net.HttpURLConnection.getHeaderField.

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

Parameters
n:int

the index of the header field

getHeaderFieldDateback to summary
public long getHeaderFieldDate(String name, long defaultValue)

Overrides java.net.HttpURLConnection.getHeaderFieldDate.

Doc from java.net.URLConnection.getHeaderFieldDate.

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.

getHeaderFieldIntback to summary
public int getHeaderFieldInt(String name, int defaultValue)

Overrides java.net.URLConnection.getHeaderFieldInt.

Doc from java.net.URLConnection.getHeaderFieldInt.

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.

getHeaderFieldKeyback to summary
public String getHeaderFieldKey(int n)

Overrides java.net.HttpURLConnection.getHeaderFieldKey.

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

Parameters
n:int

the index of the header field

getHeaderFieldLongback to summary
public long getHeaderFieldLong(String name, long defaultValue)

Overrides java.net.URLConnection.getHeaderFieldLong.

Doc from java.net.URLConnection.getHeaderFieldLong.

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.

getHeaderFieldsback to summary
public Map<String, List<String>> getHeaderFields()

Overrides java.net.URLConnection.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:Map<String, List<String>>

a Map of header fields

Since
1.4
getIfModifiedSinceback to summary
public long getIfModifiedSince()

Overrides java.net.URLConnection.getIfModifiedSince.

Doc from java.net.URLConnection.getIfModifiedSince.

Returns the value of this object's ifModifiedSince field.

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Overrides java.net.URLConnection.getInputStream.

Doc from java.net.URLConnection.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.

Exceptions
IOException:
if an I/O error occurs while creating the input stream.
getInstanceFollowRedirectsback to summary
public boolean getInstanceFollowRedirects()

Overrides java.net.HttpURLConnection.getInstanceFollowRedirects.

Doc from java.net.HttpURLConnection.getInstanceFollowRedirects.

Returns the value of this HttpURLConnection's instanceFollowRedirects field.

getLastModifiedback to summary
public long getLastModified()

Overrides java.net.URLConnection.getLastModified.

Doc from java.net.URLConnection.getLastModified.

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

getLocalCertificatesback to summary
public Certificate[] getLocalCertificates()

Implements abstract javax.net.ssl.HttpsURLConnection.getLocalCertificates.

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

getLocalPrincipalback to summary
public Principal getLocalPrincipal()

Overrides javax.net.ssl.HttpsURLConnection.getLocalPrincipal.

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

getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException

Overrides java.net.URLConnection.getOutputStream.

Doc from java.net.URLConnection.getOutputStream.

Returns an output stream that writes to this connection.

Exceptions
IOException:
if an I/O error occurs while creating the output stream.
getPeerPrincipalback to summary
public Principal getPeerPrincipal() throws SSLPeerUnverifiedException

Overrides javax.net.ssl.HttpsURLConnection.getPeerPrincipal.

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

Exceptions
SSLPeerUnverifiedException:

Doc from javax.net.ssl.HttpsURLConnection.getPeerPrincipal.

if the peer was not verified

getPermissionback to summary
public Permission getPermission() throws IOException

Overrides java.net.HttpURLConnection.getPermission.

Doc from java.net.HttpURLConnection.getPermission.

Deprecated

for removal since 25.

Returns a SocketPermission object representing the permission necessary to connect to the destination host and port.

Annotations
@Override
@Deprecated
since:25
forRemoval:true
@SuppressWarnings:removal
Exceptions
IOException:
if an error occurs while computing the permission.
getReadTimeoutback to summary
public int getReadTimeout()

Overrides java.net.URLConnection.getReadTimeout.

Doc from java.net.URLConnection.getReadTimeout.

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

getRequestMethodback to summary
public String getRequestMethod()

Overrides java.net.HttpURLConnection.getRequestMethod.

Doc from java.net.HttpURLConnection.getRequestMethod.

Get the request method.

getRequestPropertiesback to summary
public Map<String, List<String>> getRequestProperties()

Overrides java.net.URLConnection.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:Map<String, List<String>>

a Map of the general request properties for this connection.

Exceptions
IllegalStateException:
if already connected
Since
1.4
getRequestPropertyback to summary
public String getRequestProperty(String key)

Overrides java.net.URLConnection.getRequestProperty.

Doc from java.net.URLConnection.getRequestProperty.

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

getResponseCodeback to summary
public int getResponseCode() throws IOException

Overrides java.net.HttpURLConnection.getResponseCode.

Overwrite super class method

Exceptions
IOException:

Doc from java.net.HttpURLConnection.getResponseCode.

if an error occurred connecting to the server.

getResponseMessageback to summary
public String getResponseMessage() throws IOException

Overrides java.net.HttpURLConnection.getResponseMessage.

Doc from java.net.HttpURLConnection.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).
Exceptions
IOException:
if an error occurred connecting to the server.
getServerCertificatesback to summary
public Certificate[] getServerCertificates() throws SSLPeerUnverifiedException

Implements abstract javax.net.ssl.HttpsURLConnection.getServerCertificates.

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

Exceptions
SSLPeerUnverifiedException:

Doc from javax.net.ssl.HttpsURLConnection.getServerCertificates.

if the peer is not verified.

getSSLSessionback to summary
public Optional<SSLSession> getSSLSession()

Overrides javax.net.ssl.HttpsURLConnection.getSSLSession.

Doc from javax.net.ssl.HttpsURLConnection.getSSLSession.

Returns an Optional containing the SSLSession in use on this connection. Returns an empty Optional if the underlying implementation does not support this method.

Annotations
@Override
getURLback to summary
public URL getURL()

Overrides java.net.URLConnection.getURL.

Doc from java.net.URLConnection.getURL.

Returns the value of this URLConnection's URL field.

getUseCachesback to summary
public boolean getUseCaches()

Overrides java.net.URLConnection.getUseCaches.

Doc from java.net.URLConnection.getUseCaches.

Returns the value of this URLConnection's useCaches field.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

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

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 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 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 hash tables.
isConnectedback to summary
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.

setAllowUserInteractionback to summary
public void setAllowUserInteraction(boolean allowuserinteraction)

Overrides java.net.URLConnection.setAllowUserInteraction.

Doc from java.net.URLConnection.setAllowUserInteraction.

Set the value of the allowUserInteraction field of this URLConnection.

setAuthenticatorback to summary
public void setAuthenticator(Authenticator auth)

Overrides java.net.HttpURLConnection.setAuthenticator.

Doc from java.net.HttpURLConnection.setAuthenticator.

Supplies an Authenticator to be used when authentication is requested through the HTTP protocol for this HttpURLConnection. If no authenticator is supplied, the default authenticator will be used.

Annotations
@Override
setChunkedStreamingModeback to summary
public void setChunkedStreamingMode(int chunklen)

Overrides java.net.HttpURLConnection.setChunkedStreamingMode.

Doc from java.net.HttpURLConnection.setChunkedStreamingMode.

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.

setConnectedback to summary
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.

setConnectTimeoutback to summary
public void setConnectTimeout(int timeout)

Overrides java.net.URLConnection.setConnectTimeout.

Doc from java.net.URLConnection.setConnectTimeout.

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 implementation of this method may ignore the specified timeout. To see the connect timeout set, please call getConnectTimeout().

setDefaultUseCachesback to summary
public void setDefaultUseCaches(boolean defaultusecaches)

Overrides java.net.URLConnection.setDefaultUseCaches.

Doc from java.net.URLConnection.setDefaultUseCaches.

Sets the default value of the useCaches field to the specified value. This default value can be over-ridden per protocol using setDefaultUseCaches(String, boolean)

setDoInputback to summary
public void setDoInput(boolean doinput)

Overrides java.net.URLConnection.setDoInput.

Doc from java.net.URLConnection.setDoInput.

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.

setDoOutputback to summary
public void setDoOutput(boolean dooutput)

Overrides java.net.URLConnection.setDoOutput.

Doc from java.net.URLConnection.setDoOutput.

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.

setFixedLengthStreamingModeback to summary
public void setFixedLengthStreamingMode(int contentLength)

Overrides java.net.HttpURLConnection.setFixedLengthStreamingMode.

Doc from java.net.HttpURLConnection.setFixedLengthStreamingMode.

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.

Note

setFixedLengthStreamingMode(long) is recommended instead of this method as it allows larger content lengths to be set.

setFixedLengthStreamingModeback to summary
public void setFixedLengthStreamingMode(long contentLength)

Overrides java.net.HttpURLConnection.setFixedLengthStreamingMode.

Doc from java.net.HttpURLConnection.setFixedLengthStreamingMode.

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.

The content length set by invoking this method takes precedence over any value set by setFixedLengthStreamingMode(int).

setIfModifiedSinceback to summary
public void setIfModifiedSince(long ifmodifiedsince)

Overrides java.net.URLConnection.setIfModifiedSince.

Doc from java.net.URLConnection.setIfModifiedSince.

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

setInstanceFollowRedirectsback to summary
public void setInstanceFollowRedirects(boolean shouldFollow)

Overrides java.net.HttpURLConnection.setInstanceFollowRedirects.

Doc from java.net.HttpURLConnection.setInstanceFollowRedirects.

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.

setNewClientback to summary
protected void setNewClient(URL url) throws IOException

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

Parameters
url:URL

the URL being accessed

setNewClientback to summary
protected void setNewClient(URL url, boolean useCache) throws IOException

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

Parameters
url:URL

the URL being accessed

useCache:boolean

whether the cached connection should be used if present

setProxiedClientback to summary
protected void setProxiedClient(URL url, String proxyHost, int proxyPort) throws IOException

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:URL

the URL being accessed

proxyHost:String

the proxy host to use

proxyPort:int

the proxy port to use

setProxiedClientback to summary
protected void setProxiedClient(URL url, String proxyHost, int proxyPort, boolean useCache) throws IOException

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:URL

the URL being accessed

proxyHost:String

the proxy host to use

proxyPort:int

the proxy port to use

useCache:boolean

whether the cached connection should be used if present

setReadTimeoutback to summary
public void setReadTimeout(int timeout)

Overrides java.net.URLConnection.setReadTimeout.

Doc from java.net.URLConnection.setReadTimeout.

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().

setRequestMethodback to summary
public void setRequestMethod(String method) throws ProtocolException

Overrides java.net.HttpURLConnection.setRequestMethod.

Doc from java.net.HttpURLConnection.setRequestMethod.

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.
Exceptions
ProtocolException:
if the method cannot be reset or if the requested method isn't valid for HTTP.
setRequestPropertyback to summary
public void setRequestProperty(String key, String value)

Overrides java.net.URLConnection.setRequestProperty.

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

Parameters
value:String

the value to be set

setUseCachesback to summary
public void setUseCaches(boolean usecaches)

Overrides java.net.URLConnection.setUseCaches.

Doc from java.net.URLConnection.setUseCaches.

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. A default value can also be set per-protocol using setDefaultUseCaches(String, boolean).

toStringback to summary
public String toString()

Overrides java.net.URLConnection.toString.

Doc from java.net.URLConnection.toString.

Returns a String representation of this URL connection.

usingProxyback to summary
public boolean usingProxy()

Implements abstract java.net.HttpURLConnection.usingProxy.

Doc from java.net.HttpURLConnection.usingProxy.

Indicates if the connection is going through a proxy. This method returns true if the connection is known to be going or has gone through proxies, and returns false if the connection will never go through a proxy or if the use of a proxy cannot be determined.