Class AbstractRequester
- java.lang.Object
-
- com.github.dannil.scbjavaclient.communication.http.requester.AbstractRequester
-
- Direct Known Subclasses:
GETRequester
,POSTRequester
public abstract class AbstractRequester extends Object
Class which contains the logic for sending URL requests to a specified address.
- Since:
- 1.2.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRequester()
Default constructor.protected
AbstractRequester(Charset charset)
Overloaded constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Charset
getCharset()
Getter for charset.abstract HttpResponse<String>
getResponse(String url)
Retrieves the response from the specified URL.protected HttpResponse<String>
getResponse(String url, String method)
Retrieves the response from the specified URL, using the specified HTTP method.protected HttpResponse<String>
getResponse(String url, String method, String body)
Retrieves the response from the specified URL, using the specified HTTP method and request body.void
setCharset(Charset charset)
Setter for charset.
-
-
-
Constructor Detail
-
AbstractRequester
protected AbstractRequester()
Default constructor. Specifies the charset to be used for requests as UTF-8.
-
AbstractRequester
protected AbstractRequester(Charset charset)
Overloaded constructor. Loads the request properties and other data needed for the requesters.
- Parameters:
charset
- the charset to use when doing a request
-
-
Method Detail
-
getResponse
public abstract HttpResponse<String> getResponse(String url)
Retrieves the response from the specified URL.
- Parameters:
url
- the URL to call- Returns:
- the response as an
HttpResponse
-
getResponse
protected HttpResponse<String> getResponse(String url, String method) throws IOException, InterruptedException
Retrieves the response from the specified URL, using the specified HTTP method.
- Parameters:
url
- the URL to callmethod
- the HTTP method to use- Returns:
- the response as an
HttpResponse
- Throws:
IOException
- if an input/output error occurred during the requestInterruptedException
- if the request was interrupted
-
getResponse
protected HttpResponse<String> getResponse(String url, String method, String body) throws IOException, InterruptedException
Retrieves the response from the specified URL, using the specified HTTP method and request body.
- Parameters:
url
- the URL to callmethod
- the HTTP method to usebody
- the request body- Returns:
- the response as an
HttpResponse
- Throws:
IOException
- if an input/output error occurred during the requestInterruptedException
- if the request was interrupted
-
getCharset
public final Charset getCharset()
Getter for charset.
- Returns:
- the charset
-
setCharset
public final void setCharset(Charset charset)
Setter for charset.
- Parameters:
charset
- the charset
-
-