public class HttpUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ENCODING |
static java.lang.String |
GET_COMMAND |
static java.lang.String |
POST_COMMAND |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
decode(java.lang.String str)
Decodes the specified string with the default encoding defined by
ENCODING . |
static java.lang.String |
encode(java.lang.String str)
Encodes the specified string with the default encoding defined by
ENCODING . |
static HttpUtil |
getInstance() |
static void |
setProxySettings(java.lang.String host,
int port,
java.lang.String username,
java.lang.String password) |
static java.lang.String |
setUserInfo(java.lang.String url,
java.lang.String userInfos) |
HttpResponse |
submit(java.net.URL url,
byte[] request,
java.lang.String command)
Opens a connection to the specified URL and sends the specified request using
the specified submit method.
|
HttpResponse |
submit(java.net.URL url,
byte[] request,
java.lang.String command,
java.util.Map<java.lang.String,java.lang.String> headerParameters) |
public static final java.lang.String GET_COMMAND
public static final java.lang.String POST_COMMAND
public static final java.lang.String ENCODING
public static HttpUtil getInstance()
public HttpResponse submit(java.net.URL url, byte[] request, java.lang.String command) throws java.lang.Exception
url
- the URL to connect to.request
- the request to be posted.command
- the method to be used (either "GET" or "POST").java.lang.Exception
- if an error occurs.public HttpResponse submit(java.net.URL url, byte[] request, java.lang.String command, java.util.Map<java.lang.String,java.lang.String> headerParameters) throws java.lang.Exception
java.lang.Exception
public static void setProxySettings(java.lang.String host, int port, java.lang.String username, java.lang.String password)
public static java.lang.String encode(java.lang.String str)
ENCODING
.str
- the string to encode.ENCODING
,
URLEncoder.encode(String, String)
public static java.lang.String decode(java.lang.String str)
ENCODING
.str
- the string to decode.ENCODING
,
URLDecoder.decode(String, String)
public static java.lang.String setUserInfo(java.lang.String url, java.lang.String userInfos) throws java.net.MalformedURLException
java.net.MalformedURLException