public class HttpClient extends Object
Constructor and Description |
---|
HttpClient(HttpURLConnection httpConnection)
HTTP connection utility.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close connection and all possible resources.
|
List<String> |
getCookies()
Get the Cookies after the connection.
|
int |
getResponseCode()
Get the response code after the connection.
|
String |
getResponseContent()
Get the response content after the connection.
|
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(Map<String,String> queryParams)
Connect with stream data output and send queries.
|
void |
postQueryConnect(String queryParams)
Connect with stream data output and send queries by a string.
|
public HttpClient(HttpURLConnection httpConnection)
httpConnection
- - HttpURLConnection target.public void normalConnect() throws IOException
IOException
- HTTP connection failed.public void postQueryConnect(String queryParams) throws IOException
queryParams
- - A string that contains query parameters.IOException
- HTTP connection failed.public void postQueryConnect(Map<String,String> queryParams) throws IOException
queryParams
- - Key-Value query parameters.IOException
- HTTP connection failed.public void octetStreamConnect(byte[] streamBuffer, int writeBytes) throws IOException
streamBuffer
- - The buffer that contains data you want to send.writeBytes
- - How many bytes you want to send in this buffer.IOException
- HTTP connection failed.public String getResponseContent() throws IOException
IOException
- - HTTP connection failed.public int getResponseCode() throws IOException
IOException
- - HTTP connection failed.public String getResponseMessage() throws IOException
IOException
- - HTTP connection failed.public void close() throws IOException
IOException
- - HTTP connection failed.Copyright © 2018. All rights reserved.