Class SimpleHttpClient
- java.lang.Object
-
- org.n52.sensorweb.server.helgoland.adapters.web.SimpleHttpClient
-
- All Implemented Interfaces:
HttpClient
public class SimpleHttpClient extends Object implements HttpClient
-
-
Constructor Summary
Constructors Modifier Constructor Description SimpleHttpClient()Creates an instance withtimeout = 30000ms.SimpleHttpClient(int connectionTimeout)Creates an instance with a given connection timeout.SimpleHttpClient(int connectionTimeout, int socketTimeout)Creates an instance with the given timeouts.protectedSimpleHttpClient(org.apache.http.impl.client.CloseableHttpClient httpclient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ResponsedoDelete(URI url, AbstractDeleteRequest request)protected ResponsedoGet(URI url, String path, Map<String,String> header, Map<String,String> parameter)protected ResponsedoGet(URI url, AbstractGetRequest request)protected ResponsedoPost(URI url, String content, org.n52.janmayen.http.MediaType contentType)protected ResponsedoPost(URI url, AbstractPostRequest<?> request)Responseexecute(String url, AbstractRequest request)Responseexecute(URI url, AbstractRequest request)org.apache.http.HttpResponseexecuteGet(String uri)org.apache.http.HttpResponseexecuteMethod(org.apache.http.client.methods.HttpRequestBase method)org.apache.http.HttpResponseexecutePost(String uri, String payloadToSend)Sends the given payload as content-type text/xml with UTF-8 encoding to the determined URI.org.apache.http.HttpResponseexecutePost(String uri, String payloadToSend, org.n52.janmayen.http.MediaType contentType)Sends the given payload (marked to be of a specific content-type) to the determined URI.org.apache.http.HttpResponseexecutePost(String uri, org.apache.http.HttpEntity payloadToSend)Sends the given payload to the determined URI.SimpleHttpClientsetConnectionTimout(int timeout)SimpleHttpClientsetProxyHost(String proxyHost)SimpleHttpClientsetProxyPort(String proxyPort)SimpleHttpClientsetProxySslKey(boolean proxySslKey)SimpleHttpClientsetSocketTimout(int timeout)
-
-
-
Constructor Detail
-
SimpleHttpClient
public SimpleHttpClient()
Creates an instance withtimeout = 30000ms.
-
SimpleHttpClient
public SimpleHttpClient(int connectionTimeout)
Creates an instance with a given connection timeout.- Parameters:
connectionTimeout- the connection timeout in milliseconds.
-
SimpleHttpClient
public SimpleHttpClient(int connectionTimeout, int socketTimeout)Creates an instance with the given timeouts.- Parameters:
connectionTimeout- the connection timeout in milliseconds.socketTimeout- the socket timeout in milliseconds.
-
SimpleHttpClient
protected SimpleHttpClient(org.apache.http.impl.client.CloseableHttpClient httpclient)
-
-
Method Detail
-
execute
public Response execute(String url, AbstractRequest request) throws ProxyException
- Specified by:
executein interfaceHttpClient- Throws:
ProxyException
-
execute
public Response execute(URI url, AbstractRequest request) throws ProxyException
- Specified by:
executein interfaceHttpClient- Throws:
ProxyException
-
executeGet
public org.apache.http.HttpResponse executeGet(String uri) throws IOException
- Specified by:
executeGetin interfaceHttpClient- Throws:
IOException
-
executePost
public org.apache.http.HttpResponse executePost(String uri, String payloadToSend) throws IOException
Description copied from interface:HttpClientSends the given payload as content-type text/xml with UTF-8 encoding to the determined URI. Callees are responsible for ensuring that the contents are actually encoded as UTF-8. If not UTF-8, useHttpClient.executePost(String, String, MediaType)instead.- Specified by:
executePostin interfaceHttpClient- Parameters:
uri- the target to send the POST request to.payloadToSend- the POST payload as XML encoded as UTF-8.- Returns:
- the HTTP response returned by the target.
- Throws:
IOException- if sending the request fails.
-
executePost
public org.apache.http.HttpResponse executePost(String uri, String payloadToSend, org.n52.janmayen.http.MediaType contentType) throws IOException
Description copied from interface:HttpClientSends the given payload (marked to be of a specific content-type) to the determined URI.- Specified by:
executePostin interfaceHttpClient- Parameters:
uri- the target to send the POST request to.payloadToSend- the POST payload as XML.contentType- the content-type of the payload.- Returns:
- the HTTP response returned by the target.
- Throws:
IOException- if sending the request fails.
-
executePost
public org.apache.http.HttpResponse executePost(String uri, org.apache.http.HttpEntity payloadToSend) throws IOException
Description copied from interface:HttpClientSends the given payload to the determined URI. Refer to the HTTP components docs to get more information which entity types are possible.- Specified by:
executePostin interfaceHttpClient- Parameters:
uri- the target to send the POST request to.payloadToSend- a more generic way to send arbitrary content.- Returns:
- the HTTP response returned by the target.
- Throws:
IOException- if sending the request fails.
-
executeMethod
public org.apache.http.HttpResponse executeMethod(org.apache.http.client.methods.HttpRequestBase method) throws IOException- Specified by:
executeMethodin interfaceHttpClient- Parameters:
method- the HTTP method to execute.- Returns:
- the HTTP response returned by the target.
- Throws:
IOException- if sending the request fails
-
setConnectionTimout
public SimpleHttpClient setConnectionTimout(int timeout)
-
setSocketTimout
public SimpleHttpClient setSocketTimout(int timeout)
-
setProxyHost
public SimpleHttpClient setProxyHost(String proxyHost)
-
setProxyPort
public SimpleHttpClient setProxyPort(String proxyPort)
-
setProxySslKey
public SimpleHttpClient setProxySslKey(boolean proxySslKey)
-
doGet
protected Response doGet(URI url, AbstractGetRequest request) throws ProxyException
- Throws:
ProxyException
-
doGet
protected Response doGet(URI url, String path, Map<String,String> header, Map<String,String> parameter) throws ProxyException
- Throws:
ProxyException
-
doPost
protected Response doPost(URI url, AbstractPostRequest<?> request) throws ProxyException
- Throws:
ProxyException
-
doPost
protected Response doPost(URI url, String content, org.n52.janmayen.http.MediaType contentType) throws ProxyException
- Throws:
ProxyException
-
doDelete
protected Response doDelete(URI url, AbstractDeleteRequest request) throws ProxyException
- Throws:
ProxyException
-
-