Interface JdbcDriverDownloader.UrlConnectionWrapper
-
- Enclosing class:
- JdbcDriverDownloader
public static interface JdbcDriverDownloader.UrlConnectionWrapperA 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 CharsetgetCharset()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}.longgetContentLength()Returns the value of theContent-Lengthheader field.InputStreamgetInputStream()Returns an input stream that reads from this open connection.intgetResponseCode()Gets the status code from an HTTP response message.StringgetResponseMessage()Gets the HTTP response message, if any, returned along with the response code from a server.
-
-
-
Method Detail
-
getResponseCode
int getResponseCode() throws IOExceptionGets 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
nullif 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-Lengthheader field. Necessary for the correct download progress monitoring.- Returns:
- the content length of the resource that this connection's URL
references, or
-1Lif 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
SocketTimeoutExceptioncan 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()
-
-