Class WebUtilitiesKt
-
- All Implemented Interfaces:
public final class WebUtilitiesKt
-
-
Method Summary
Modifier and Type Method Description final static URLConnectiontimedConnection(URL $self, Integer connectTimeout, Integer readTimeout)Opens a connection to this URL with connectTimeout and readTimeout applied, in milliseconds. -
-
Method Detail
-
timedConnection
final static URLConnection timedConnection(URL $self, Integer connectTimeout, Integer readTimeout)
Opens a connection to this URL with connectTimeout and readTimeout applied, in milliseconds.
The single place that knows how a timeout is applied. WebUtilities.openTimedConnection is the usual way in and supplies the configured values, but the settings groups cannot use it —
WebUtilitiesis constructed fromApiProperties, so a group insideApiPropertiesreaching for it would close a cycle. They call this directly with values from their own de.griefed.serverpackcreator.api.settings.NetworkConfig instead, which keeps the mechanism in one place even though the values arrive by two routes.Returns URLConnection, not
HttpURLConnection: the timeout setters live onURLConnection, and afile:URL yields aFileURLConnectionwhose cast would throwClassCastException— which is not anIOException, and so escapes callers' error handling. Callers needingresponseCodecast themselves.- Parameters:
connectTimeout- Milliseconds to wait for the connection.readTimeout- Milliseconds a single read may block.
-
-
-
-