Package com.kheops.util
Class HttpUtil
java.lang.Object
com.kheops.util.HttpUtil
A usefull class to send request to a HTTP server.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Decodes the specified string with the default encoding defined byENCODING
.static String
Encodes the specified string with the default encoding defined byENCODING
.static HttpUtil
static void
setProxySettings
(String host, int port, String username, String password) static String
setUserInfo
(String url, String userInfos) Opens a connection to the specified URL and sends the specified request using the specified submit method.
-
Field Details
-
GET_COMMAND
- See Also:
-
POST_COMMAND
- See Also:
-
ENCODING
- See Also:
-
-
Method Details
-
getInstance
-
submit
Opens a connection to the specified URL and sends the specified request using the specified submit method.- Parameters:
url
- the URL to connect to.request
- the request to be posted.command
- the method to be used (either "GET" or "POST").- Returns:
- a HttpResponse that contains the server's response.
- Throws:
Exception
- if an error occurs.
-
submit
public HttpResponse submit(URL url, byte[] request, String command, Map<String, String> headerParameters) throws Exception- Throws:
Exception
-
setProxySettings
-
encode
Encodes the specified string with the default encoding defined byENCODING
.- Parameters:
str
- the string to encode.- Returns:
- the encoded string.
- See Also:
-
decode
Decodes the specified string with the default encoding defined byENCODING
.- Parameters:
str
- the string to decode.- Returns:
- the decoded string.
- See Also:
-
setUserInfo
- Throws:
MalformedURLException
-