Package com.github.alexdlaird.http
Class DefaultHttpClient
- java.lang.Object
-
- com.github.alexdlaird.http.DefaultHttpClient
-
- All Implemented Interfaces:
HttpClient
public class DefaultHttpClient extends java.lang.Object implements HttpClient
Implementation of a default client for executing JSON-based HTTP requests.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultHttpClient.Builder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.net.HttpURLConnection
createHttpUrlConnection(java.lang.String url)
Override this method if you could like to implement a custom URL connection.<B> Response<B>
delete(java.lang.String uri, java.util.List<Parameter> parameters, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.Class<B> clazz)
Perform DELETE operation against an endpoint.<B> Response<B>
get(java.lang.String uri, java.util.List<Parameter> parameters, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.Class<B> clazz)
Perform GET operation against an endpoint.<R,B>
Response<B>post(java.lang.String uri, R request, java.util.List<Parameter> parameters, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.Class<B> clazz)
Perform POST operation against an endpoint.<R,B>
Response<B>put(java.lang.String uri, R request, java.util.List<Parameter> parameters, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.Class<B> clazz)
Perform PUT operation against an endpoint.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.alexdlaird.http.HttpClient
delete, modifyConnection
-
-
-
-
Method Detail
-
get
public <B> Response<B> get(java.lang.String uri, java.util.List<Parameter> parameters, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.Class<B> clazz)
Description copied from interface:HttpClient
Perform GET operation against an endpoint.- Specified by:
get
in interfaceHttpClient
- Parameters:
uri
- The URL relative to the base URL on which to perform the operation.parameters
- An arbitrary number of parameters to add to the URL.additionalHeaders
- Additional headers for the request.clazz
- The class for the Response's body.- Returns:
- The results of the query.
-
post
public <R,B> Response<B> post(java.lang.String uri, R request, java.util.List<Parameter> parameters, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.Class<B> clazz)
Description copied from interface:HttpClient
Perform POST operation against an endpoint.- Specified by:
post
in interfaceHttpClient
- Parameters:
uri
- The URL relative to the base URL on which to perform the operation.request
- The element to be serialized into the request body.parameters
- An arbitrary number of parameters to add to the URL.additionalHeaders
- Additional headers for the request.clazz
- The class for the Response's body.- Returns:
- The results of the query.
-
put
public <R,B> Response<B> put(java.lang.String uri, R request, java.util.List<Parameter> parameters, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.Class<B> clazz)
Description copied from interface:HttpClient
Perform PUT operation against an endpoint.- Specified by:
put
in interfaceHttpClient
- Parameters:
uri
- The URL relative to the base URL on which to perform the operation.request
- The element to be serialized into the request body.parameters
- An arbitrary number of parameters to add to the URL.additionalHeaders
- Additional headers for the request.clazz
- The class for the Response's body.- Returns:
- The results of the query.
-
delete
public <B> Response<B> delete(java.lang.String uri, java.util.List<Parameter> parameters, java.util.Map<java.lang.String,java.lang.String> additionalHeaders, java.lang.Class<B> clazz)
Description copied from interface:HttpClient
Perform DELETE operation against an endpoint.- Specified by:
delete
in interfaceHttpClient
- Parameters:
uri
- The URL relative to the base URL on which to perform the operation.parameters
- An arbitrary number of parameters to add to the URL.additionalHeaders
- Additional headers for the request.clazz
- The class for the Response's body.- Returns:
- The results of the query.
-
createHttpUrlConnection
protected java.net.HttpURLConnection createHttpUrlConnection(java.lang.String url) throws java.io.IOException
Override this method if you could like to implement a custom URL connection.- Parameters:
url
- The URL to connect to.- Returns:
- A URL connection.
- Throws:
java.io.IOException
- An I/O exception has occurred.
-
-