Klasse HttpRequest
java.lang.Object
de.oliver.fancyanalytics.api.http.HttpRequest
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungHttpRequest(String url) Constructs a new HttpRequest with the provided URL, method, body, and headers. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibunggetBody()getUrl()send()Sends an HTTP request based on preset configuration including URL, method, body, and headers.Sets the body of the request.withHeader(String key, String value) Adds a header to the request.withHeaders(Map<String, String> headers) Sets the headers of the request.withMethod(String method) Sets the method of the request.
-
Konstruktordetails
-
HttpRequest
Constructs a new HttpRequest with the provided URL, method, body, and headers.- Parameter:
url- The URL to which the request is directed.method- The HTTP method to use (e.g., GET, POST).body- The body of the request. This can be any object that needs to be sent in the request body.headers- A map representing the headers to be included in the request, where the key is the header name and the value is the header value.
-
HttpRequest
-
-
Methodendetails
-
send
Sends an HTTP request based on preset configuration including URL, method, body, and headers.- Gibt zurück:
- the HttpResponse containing the response as a string from the executed HTTP request.
- Löst aus:
URISyntaxException- if the URL is not properly formatted.IOException- if an I/O error occurs when sending or receiving.InterruptedException- if the operation is interrupted.
-
getUrl
-
getMethod
-
withMethod
Sets the method of the request.- Parameter:
method- The method to use.- Gibt zurück:
- The HttpRequest.
-
getBody
-
withBody
Sets the body of the request.- Parameter:
body- The body of the request.- Gibt zurück:
- The HttpRequest.
-
getHeaders
-
withHeaders
Sets the headers of the request.- Parameter:
headers- The headers of the request.- Gibt zurück:
- The HttpRequest.
-
withHeader
Adds a header to the request.- Parameter:
key- The key of the header.value- The value of the header.- Gibt zurück:
- The HttpRequest.
-