Package com._1c.g5.v8.dt.common
Class HttpUtil
java.lang.Object
com._1c.g5.v8.dt.common.HttpUtil
HTTP validation and hint water marks utility methods and constants.
- Restriction:
- This class is not intended to be sub-classed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Returns a free port number onlocalhost
, or-1
if unable to find a free port.static String
Returns the host name.static boolean
isAvailable
(int port) Returns whether the given port is available on the current PC.static boolean
isValidUrl
(String url) Validates whether given URL is in valid format.static String
Tries to get and return host name.static org.eclipse.core.runtime.IStatus
validateUri
(String uri) Validates whether given URI is in valid format.static org.eclipse.core.runtime.IStatus
validateUrl
(String url) Validates whether given URL is in valid format.
-
Field Details
-
WATERMARK_DEBUG_URL
Hint water mark for debug server URL. Value is "http://debug_host:debug_port/".- See Also:
-
WATERMARK_LAUNCH_URL
Hint water mark for launch URL. Value is "http://launch_host:launch_port/".- See Also:
-
WATERMARK_URL
Hint water mark for abstract URL. Value is "http://host:port".- See Also:
-
LOCALHOST
- See Also:
-
HTTP
- See Also:
-
HTTPS
- See Also:
-
MIN_PORT_NUMBER
public static final int MIN_PORT_NUMBER- See Also:
-
MAX_PORT_NUMBER
public static final int MAX_PORT_NUMBER- See Also:
-
-
Method Details
-
isValidUrl
Validates whether given URL is in valid format.- Parameters:
url
- URL to validate, can benull
thenfalse
will be returned- Returns:
- whether given URL is in valid format
-
validateUrl
Validates whether given URL is in valid format.- Parameters:
url
- URL to validate, cannot benull
- Returns:
- OK status if given URL is in valid format, or ERROR status with description of throwable
-
validateUri
Validates whether given URI is in valid format.- Parameters:
uri
- the URI to validate, cannot benull
- Returns:
- OK status if given URI is in valid format, or ERROR status with description of throwable
-
findFreePort
public static int findFreePort()Returns a free port number onlocalhost
, or-1
if unable to find a free port.- Returns:
- a free port number on
localhost
, or-1
if unable to find a free port
-
isAvailable
public static boolean isAvailable(int port) Returns whether the given port is available on the current PC.- Parameters:
port
- the port to check, must be positive and less or equal to65535
- Returns:
- whether the given port is available on the current PC
-
getHostName
Returns the host name. Can returnnull
if not found or error occurred.- Returns:
- the host name or
null
if not found - Throws:
UnknownHostException
- if the local host name could not be resolved into an address
-
tryGetHostName
Tries to get and return host name. If cannot get, returnslocalhost
- Returns:
- the host name or
localhost
if cannot get
-