Package com._1c.g5.v8.dt.common
Class HttpUtil
- java.lang.Object
-
- com._1c.g5.v8.dt.common.HttpUtil
-
public final class HttpUtil extends Object
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 Modifier and Type Field Description static String
HTTP
static String
HTTPS
static String
LOCALHOST
static int
MAX_PORT_NUMBER
static int
MIN_PORT_NUMBER
static String
WATERMARK_DEBUG_URL
Hint water mark for debug server URL.static String
WATERMARK_LAUNCH_URL
Hint water mark for launch URL.static String
WATERMARK_URL
Hint water mark for abstract URL.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
findFreePort()
Returns a free port number onlocalhost
, or-1
if unable to find a free port.static String
getHostName()
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
tryGetHostName()
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 Detail
-
WATERMARK_DEBUG_URL
public static final String WATERMARK_DEBUG_URL
Hint water mark for debug server URL. Value is "http://debug_host:debug_port/".- See Also:
- Constant Field Values
-
WATERMARK_LAUNCH_URL
public static final String WATERMARK_LAUNCH_URL
Hint water mark for launch URL. Value is "http://launch_host:launch_port/".- See Also:
- Constant Field Values
-
WATERMARK_URL
public static final String WATERMARK_URL
Hint water mark for abstract URL. Value is "http://host:port".- See Also:
- Constant Field Values
-
LOCALHOST
public static final String LOCALHOST
- See Also:
- Constant Field Values
-
HTTP
public static final String HTTP
- See Also:
- Constant Field Values
-
HTTPS
public static final String HTTPS
- See Also:
- Constant Field Values
-
MIN_PORT_NUMBER
public static final int MIN_PORT_NUMBER
- See Also:
- Constant Field Values
-
MAX_PORT_NUMBER
public static final int MAX_PORT_NUMBER
- See Also:
- Constant Field Values
-
-
Method Detail
-
isValidUrl
public static boolean isValidUrl(String url)
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
public static org.eclipse.core.runtime.IStatus validateUrl(String url)
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
public static org.eclipse.core.runtime.IStatus validateUri(String uri)
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
public static String getHostName() throws UnknownHostException
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
public static String tryGetHostName()
Tries to get and return host name. If cannot get, returnslocalhost
- Returns:
- the host name or
localhost
if cannot get
-
-