public class HTTPClient
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
ShowConnectionTrace |
| Constructor and Description |
|---|
HTTPClient(java.lang.String url)
'GET' request.
|
HTTPClient(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> params)
'POST' request with URL encoded parameters.
|
HTTPClient(java.lang.String url,
MultipartData params)
'POST' request with MultipartData parameters.
|
HTTPClient(java.lang.String url,
java.lang.String method)
'GET' or 'POST' request.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getByteArrayResponse()
Get the response as byte array.
|
byte[] |
getByteArrayResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
Get the response as byte array.
|
byte[] |
getByteArrayResponse(javax.net.ssl.SSLSocketFactory socketFactory)
Get the response as byte array.
|
byte[] |
getByteArrayResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
Get the response as byte array.
|
int |
getLastResponse()
Get the HTTP response code of the last request.
|
int |
getResponse()
Establish the connection and returns the status.
|
int |
getResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
Establish the connection and returns the status.
|
int |
getResponse(javax.net.ssl.SSLSocketFactory socketFactory)
Establish the connection and returns the status.
|
int |
getResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
Establish the connection and returns the status.
|
java.io.InputStream |
getStreamResponse()
Get the response as stream.
|
java.io.InputStream |
getStreamResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
Get the response as stream.
|
java.io.InputStream |
getStreamResponse(javax.net.ssl.SSLSocketFactory socketFactory)
Get the response as stream.
|
java.io.InputStream |
getStreamResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
Get the response as stream.
|
java.lang.String |
getStringResponse()
Get the response as string encoded in 'UTF-8'.
|
java.lang.String |
getStringResponse(java.nio.charset.Charset charset)
Get the response as string.
|
java.lang.String |
getStringResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
Get the response as string encoded in 'UTF-8'.
|
java.lang.String |
getStringResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties,
java.nio.charset.Charset charset)
Get the response as string.
|
java.lang.String |
getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory)
Get the response as string encoded in 'UTF-8'.
|
java.lang.String |
getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.nio.charset.Charset charset)
Get the response as string.
|
java.lang.String |
getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
Get the response as string.
|
java.lang.String |
getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties,
java.nio.charset.Charset charset)
Get the response as string.
|
public HTTPClient(java.lang.String url)
url - URL to connect.public HTTPClient(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> params)
url - URL to connect.params - List of pair parameter name and value to send.public HTTPClient(java.lang.String url,
MultipartData params)
url - URL to connect.params - MultipartData parameter data to send.public HTTPClient(java.lang.String url,
java.lang.String method)
url - URL to connect.method - 'GET' or 'POST'.public byte[] getByteArrayResponse()
throws java.io.IOException
java.io.IOExceptionpublic byte[] getByteArrayResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
throws java.io.IOException
requestProperties - List of pair property and value to specify in the request.java.io.IOExceptionpublic byte[] getByteArrayResponse(javax.net.ssl.SSLSocketFactory socketFactory)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.java.io.IOExceptionpublic byte[] getByteArrayResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.requestProperties - List of pair property and value to specify in the request.java.io.IOExceptionpublic int getLastResponse()
throws java.io.IOException
java.io.IOException - if there is no previous request.public int getResponse()
throws java.io.IOException
java.io.IOExceptionpublic int getResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
throws java.io.IOException
requestProperties - List of pair property and value to specify in the request.java.io.IOExceptionpublic int getResponse(javax.net.ssl.SSLSocketFactory socketFactory)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.java.io.IOExceptionpublic int getResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.requestProperties - List of pair property and value to specify in the request.java.io.IOExceptionpublic java.io.InputStream getStreamResponse()
throws java.io.IOException
java.io.IOExceptionpublic java.io.InputStream getStreamResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
throws java.io.IOException
requestProperties - List of pair property and value to specify in the request.java.io.IOExceptionpublic java.io.InputStream getStreamResponse(javax.net.ssl.SSLSocketFactory socketFactory)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.java.io.IOExceptionpublic java.io.InputStream getStreamResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.requestProperties - List of pair property and value to specify in the request.java.io.IOExceptionpublic java.lang.String getStringResponse()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getStringResponse(java.nio.charset.Charset charset)
throws java.io.IOException
charset - Character encoding.java.io.IOExceptionpublic java.lang.String getStringResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties)
throws java.io.IOException
requestProperties - List of pair property and value to specify in the request.java.io.IOExceptionpublic java.lang.String getStringResponse(java.util.Map<java.lang.String,java.lang.String> requestProperties,
java.nio.charset.Charset charset)
throws java.io.IOException
requestProperties - List of pair property and value to specify in the request.charset - Character encoding.java.io.IOExceptionpublic java.lang.String getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.java.io.IOExceptionpublic java.lang.String getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.nio.charset.Charset charset)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.charset - Character encoding.java.io.IOExceptionpublic java.lang.String getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.requestProperties - java.io.IOExceptionpublic java.lang.String getStringResponse(javax.net.ssl.SSLSocketFactory socketFactory,
java.util.Map<java.lang.String,java.lang.String> requestProperties,
java.nio.charset.Charset charset)
throws java.io.IOException
socketFactory - Underlying factory of sockets to use by the connection.requestProperties - List of pair property and value to specify in the request.charset - java.io.IOException