Class HttpUtils
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.util.HttpUtils
 
- 
 public class HttpUtils extends java.lang.ObjectFilename: HttpUtils Author: Perry Arellano-Jones Created on: 8/14/15This class provides some simple connectivity utilities which may be common when trying to get information about an HTTP connection. 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classHttpUtils.TrustAllX509TrustManager
 - 
Field SummaryFields Modifier and Type Field Description static intRESPONSE_OKstatic java.util.regex.PatternVALID_URL_PATTERN
 - 
Constructor SummaryConstructors Constructor Description HttpUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisOkResponse(java.lang.String address)This static method will try to resolve a URL passed in as a string, and if successful, will try to determine if the response given is an "OK" response (aka, code 200).static booleanisOkResponse(java.lang.String address, int timeout)This static method will try to resolve a URL passed in as a string, and if successful, will try to determine if the response given is an "OK" response (aka, code 200).static booleanisOkResponse(java.net.URL url)Makes a test connection to the provided URL.static booleanisOkResponse(java.net.URL url, int timeout)static booleanisValidUrl(java.lang.String url)Tests the url for valid format.
 
- 
- 
- 
Field Detail- 
RESPONSE_OKpublic static final int RESPONSE_OK - See Also:
- Constant Field Values
 
 - 
VALID_URL_PATTERNpublic static final java.util.regex.Pattern VALID_URL_PATTERN 
 
- 
 - 
Method Detail- 
isOkResponsepublic static boolean isOkResponse(java.net.URL url) throws java.io.IOExceptionMakes a test connection to the provided URL. If the response has a 200 "OK" code, the method returns true. If the response is anything other than 200, this method returns false.This method is useful when trying to verify that a URL is online and has a valid site available. Omitting the timeout parameter uses 0, or an infinite timeout - Parameters:
- url- the URL that will be tested for connection/content quality.
- Returns:
- true when the GET request of the url is responded to with a code 200
- Throws:
- java.io.IOException
 
 - 
isOkResponsepublic static boolean isOkResponse(java.net.URL url, int timeout) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
isOkResponsepublic static boolean isOkResponse(java.lang.String address) throws java.net.MalformedURLExceptionThis static method will try to resolve a URL passed in as a string, and if successful, will try to determine if the response given is an "OK" response (aka, code 200). On success it returns true. All other response codes return false.- Parameters:
- address- which is the url to be tested for connectivity
- Returns:
- true when the given string resolves to an http or https connection that gives a code 200 response
- Throws:
- java.net.MalformedURLException
 
 - 
isOkResponsepublic static boolean isOkResponse(java.lang.String address, int timeout) throws java.net.MalformedURLExceptionThis static method will try to resolve a URL passed in as a string, and if successful, will try to determine if the response given is an "OK" response (aka, code 200). On success it returns true. All other response codes return false.- Parameters:
- address- which is the url to be tested for connectivity
- timeout- connection timeout in millis
- Returns:
- true when the given string resolves to an http or https connection that gives a code 200 response
- Throws:
- java.net.MalformedURLException
 
 - 
isValidUrlpublic static boolean isValidUrl(java.lang.String url) Tests the url for valid format. Does not attempt to resolve or validate beyond the syntactic structure of the string.- Parameters:
- url- url to test
- Returns:
- false if invalid or url was null
 
 
- 
 
-