public class HTTPClient extends java.lang.Object implements HTTPConnector
Modifier and Type | Field and Description |
---|---|
protected org.apache.http.impl.client.CloseableHttpClient |
client |
protected java.lang.String |
uri |
ACTION_DELETE, ACTION_GET, ACTION_HEAD, ACTION_POST, ACTION_PUT
Constructor and Description |
---|
HTTPClient(java.util.Map props)
Creates new HTTPClient
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
doDelete(java.lang.String urlStr,
java.util.Map extra,
java.lang.StringBuffer response)
It sends a DELETE request to the HTTP server with urlStr and loads the
response header to the provided StringBuffer.
|
int |
doDelete(java.lang.String urlStr,
java.lang.StringBuffer response) |
int |
doGet(java.lang.String urlStr,
java.util.Map extra,
java.lang.StringBuffer response,
java.io.OutputStream out)
It sends a GET request to the HTTP server with the urlStr and the extra
request headers stored in the Map.
|
int |
doGet(java.lang.String urlStr,
java.lang.StringBuffer response)
It sends a GET request to the HTTP server with the urlStr.
|
int |
doGet(java.lang.String urlStr,
java.lang.StringBuffer response,
java.io.OutputStream out) |
int |
doHead(java.lang.String urlStr,
java.util.Map extra,
java.lang.StringBuffer response)
It sends a HEAD request to the HTTP server with the urlStr and loads the
response header to the provided StringBuffer.
|
int |
doHead(java.lang.String urlStr,
java.lang.StringBuffer response) |
int |
doPost(java.lang.String urlStr,
BytesBuffer buf,
java.lang.StringBuffer response)
It sends a POST request to the HTTP server with the urlStr and the
request content stored in the byte buffer.
|
int |
doPost(java.lang.String urlStr,
BytesBuffer buf,
java.lang.StringBuffer response,
java.io.OutputStream out) |
int |
doPost(java.lang.String urlStr,
java.util.Map extra,
BytesBuffer buf,
java.lang.StringBuffer response) |
int |
doPost(java.lang.String urlStr,
java.util.Map extra,
BytesBuffer buf,
java.lang.StringBuffer response,
java.io.OutputStream out)
It sends a POST request to the HTTP server with the urlStr and the extra
request headers, as well as the content stored in the BytesBuffer.
|
int |
doPost(java.lang.String urlStr,
java.util.Map extra,
java.lang.String line,
java.lang.StringBuffer response) |
int |
doPost(java.lang.String urlStr,
java.lang.String line,
java.lang.StringBuffer response) |
int |
doPut(java.lang.String urlStr,
BytesBuffer buf,
java.lang.StringBuffer response,
java.io.OutputStream out) |
int |
doPut(java.lang.String urlStr,
java.util.Map extra,
BytesBuffer buf,
java.lang.StringBuffer response,
java.io.OutputStream out)
It sends a PUT request to the HTTP server with the urlStr and the extra
request headers, as well as the content stored in the BytesBuffer.
|
java.lang.String |
getURI() |
boolean |
isConnected()
returns true since it is connectionless
|
boolean |
isHTTPS() |
boolean |
isPost() |
static void |
main(java.lang.String[] args) |
java.lang.String |
reconnect()
It reconnects and returns null or error message upon failure
|
protected org.apache.http.impl.client.CloseableHttpClient client
protected java.lang.String uri
public int doGet(java.lang.String urlStr, java.util.Map extra, java.lang.StringBuffer response, java.io.OutputStream out) throws java.io.IOException
doGet
in interface HTTPConnector
java.io.IOException
public int doGet(java.lang.String urlStr, java.lang.StringBuffer response, java.io.OutputStream out) throws java.io.IOException
doGet
in interface HTTPConnector
java.io.IOException
public int doGet(java.lang.String urlStr, java.lang.StringBuffer response) throws java.io.IOException
doGet
in interface HTTPConnector
java.io.IOException
public int doPost(java.lang.String urlStr, java.util.Map extra, BytesBuffer buf, java.lang.StringBuffer response, java.io.OutputStream out) throws java.io.IOException
doPost
in interface HTTPConnector
java.io.IOException
public int doPost(java.lang.String urlStr, BytesBuffer buf, java.lang.StringBuffer response, java.io.OutputStream out) throws java.io.IOException
doPost
in interface HTTPConnector
java.io.IOException
public int doPost(java.lang.String urlStr, BytesBuffer buf, java.lang.StringBuffer response) throws java.io.IOException
doPost
in interface HTTPConnector
java.io.IOException
public int doPost(java.lang.String urlStr, java.lang.String line, java.lang.StringBuffer response) throws java.io.IOException
doPost
in interface HTTPConnector
java.io.IOException
public int doPost(java.lang.String urlStr, java.util.Map extra, BytesBuffer buf, java.lang.StringBuffer response) throws java.io.IOException
doPost
in interface HTTPConnector
java.io.IOException
public int doPost(java.lang.String urlStr, java.util.Map extra, java.lang.String line, java.lang.StringBuffer response) throws java.io.IOException
doPost
in interface HTTPConnector
java.io.IOException
public int doPut(java.lang.String urlStr, java.util.Map extra, BytesBuffer buf, java.lang.StringBuffer response, java.io.OutputStream out) throws java.io.IOException
doPut
in interface HTTPConnector
java.io.IOException
public int doPut(java.lang.String urlStr, BytesBuffer buf, java.lang.StringBuffer response, java.io.OutputStream out) throws java.io.IOException
doPut
in interface HTTPConnector
java.io.IOException
public int doHead(java.lang.String urlStr, java.util.Map extra, java.lang.StringBuffer response) throws java.io.IOException
doHead
in interface HTTPConnector
java.io.IOException
public int doHead(java.lang.String urlStr, java.lang.StringBuffer response) throws java.io.IOException
doHead
in interface HTTPConnector
java.io.IOException
public int doDelete(java.lang.String urlStr, java.util.Map extra, java.lang.StringBuffer response) throws java.io.IOException
doDelete
in interface HTTPConnector
java.io.IOException
public int doDelete(java.lang.String urlStr, java.lang.StringBuffer response) throws java.io.IOException
doDelete
in interface HTTPConnector
java.io.IOException
public void close()
close
in interface HTTPConnector
public boolean isPost()
isPost
in interface HTTPConnector
public boolean isHTTPS()
isHTTPS
in interface HTTPConnector
public java.lang.String getURI()
getURI
in interface HTTPConnector
public boolean isConnected()
isConnected
in interface HTTPConnector
public java.lang.String reconnect()
reconnect
in interface HTTPConnector
public static void main(java.lang.String[] args)