public class HttpClient
extends java.lang.Object
Constructor and Description |
---|
HttpClient(java.net.HttpURLConnection httpConnection)
HTTP connection utility.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close connection and all possible resources.
|
java.util.List<java.lang.String> |
getCookies()
Get the Cookies after the connection.
|
int |
getResponseCode()
Get the response code after the connection.
|
java.lang.String |
getResponseContent()
Get the response content after the connection.
|
java.lang.String |
getResponseMessage()
Get the response message after the connection.
|
void |
normalConnect()
Connect without stream data output.
|
void |
octetStreamConnect(byte[] streamBuffer,
int writeBytes)
Connect and send data by "Content-Type: application/octet-stream".
|
void |
postQueryConnect(java.util.Map<java.lang.String,java.lang.String> queryParams)
Connect with stream data output and send queries.
|
void |
postQueryConnect(java.lang.String queryParams)
Connect with stream data output and send queries by a string.
|
public HttpClient(java.net.HttpURLConnection httpConnection)
httpConnection
- - HttpURLConnection target.public void normalConnect() throws java.io.IOException
java.io.IOException
- HTTP connection failed.public void postQueryConnect(java.lang.String queryParams) throws java.io.IOException
queryParams
- - A string that contains query parameters.java.io.IOException
- HTTP connection failed.public void postQueryConnect(java.util.Map<java.lang.String,java.lang.String> queryParams) throws java.io.IOException
queryParams
- - Key-Value query parameters.java.io.IOException
- HTTP connection failed.public void octetStreamConnect(byte[] streamBuffer, int writeBytes) throws java.io.IOException
streamBuffer
- - The buffer that contains data you want to send.writeBytes
- - How many bytes you want to send in this buffer.java.io.IOException
- HTTP connection failed.public java.lang.String getResponseContent() throws java.io.IOException
java.io.IOException
- - HTTP connection failed.public int getResponseCode() throws java.io.IOException
java.io.IOException
- - HTTP connection failed.public java.lang.String getResponseMessage() throws java.io.IOException
java.io.IOException
- - HTTP connection failed.public java.util.List<java.lang.String> getCookies()
public void close() throws java.io.IOException
java.io.IOException
- - HTTP connection failed.