Class CloseableConnection
java.lang.Object
net.adoptopenjdk.icedteaweb.http.CloseableConnection
- All Implemented Interfaces:
Closeable, AutoCloseable
- Direct Known Subclasses:
CloseableHttpConnection
Closeable wrapper around a URLConnection.
Only the needed methods of URLConnection are exposed.
Additionally getResponseCode() from HttpURLConnection is available.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()does nothing.longdelegates toURLConnection.getContentLengthLong()getHeaderField(String name) delegates toURLConnection.getHeaderField(String)delegates toURLConnection.getHeaderFields()delegates toURLConnection.getInputStream()longdelegates toURLConnection.getLastModified()delegates toURLConnection.getPermission()intalways returnsHttpURLConnection.HTTP_OK.getURL()delegates toURLConnection.getURL()voidsetConnectTimeout(int timeout)
-
Field Details
-
delegate
-
-
Constructor Details
-
CloseableConnection
CloseableConnection(URLConnection delegate)
-
-
Method Details
-
close
public void close()does nothing. Subclasses may change this behavior- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getResponseCode
always returnsHttpURLConnection.HTTP_OK. Subclasses may change this behavior- Throws:
IOException
-
getURL
delegates toURLConnection.getURL() -
getInputStream
delegates toURLConnection.getInputStream()- Throws:
IOException
-
getPermission
delegates toURLConnection.getPermission()- Throws:
IOException
-
getHeaderFields
delegates toURLConnection.getHeaderFields() -
getHeaderField
delegates toURLConnection.getHeaderField(String) -
getLocationHeaderFieldUrl
- Returns:
- HTTP header field "Location" as URL
- Throws:
MalformedURLException- if the location string does not represent a valid URL
-
getLastModified
public long getLastModified()delegates toURLConnection.getLastModified() -
getContentLength
public long getContentLength()delegates toURLConnection.getContentLengthLong() -
setConnectTimeout
public void setConnectTimeout(int timeout)
-