Interface JdbcDriverDownloader.UrlConnectionWrapper
-
- Enclosing class:
- JdbcDriverDownloader
public static interface JdbcDriverDownloader.UrlConnectionWrapper
A wrapper around an open connection to a (local or remote) URL.
- Since:
- 2018.1
- Author:
- Andrey Shcheglov <mailto:andrey.shcheglov@jetbrains.com>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Charset
getCharset()
Returns the charset specified in the HTTP {code Content-Type} header field, or the default charset value safe enough to handle this {code Content-Type}.long
getContentLength()
Returns the value of theContent-Length
header field.InputStream
getInputStream()
Returns an input stream that reads from this open connection.int
getResponseCode()
Gets the status code from an HTTP response message.String
getResponseMessage()
Gets the HTTP response message, if any, returned along with the response code from a server.
-
-
-
Method Detail
-
getResponseCode
int getResponseCode() throws IOException
Gets the status code from an HTTP response message. Returns -1 if no code can be discerned from the response (i. e., the response is not valid HTTP).
- Returns:
- the HTTP Status-Code, or -1.
- Throws:
IOException
- if an error occurred connecting to the server.- See Also:
HttpURLConnection.getResponseCode()
-
getResponseMessage
@Nullable String getResponseMessage() throws IOException
Gets the HTTP response message, if any, returned along with the response code from a server. 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
- if an error occurred connecting to the server.- See Also:
HttpURLConnection.getResponseMessage()
-
getContentLength
long getContentLength()
Returns the value of the
Content-Length
header field. Necessary for the correct download progress monitoring.- Returns:
- the content length of the resource that this connection's URL
references, or
-1L
if the content length is not known. - See Also:
URLConnection.getContentLength()
-
getCharset
@NotNull Charset getCharset()
Returns the charset specified in the HTTP {code Content-Type} header field, or the default charset value safe enough to handle this {code Content-Type}.
- Returns:
- the charset specified in the HTTP {code Content-Type} header field, or the default value.
-
getInputStream
@NotNull InputStream getInputStream() throws IOException
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
- if an I/O error occurs while creating the input stream.UnknownServiceException
- if the protocol does not support input.- See Also:
URLConnection.getInputStream()
,URLConnection.setReadTimeout(int)
,URLConnection.getReadTimeout()
-
-