Klasse HttpRequest

java.lang.Object
de.oliver.fancyanalytics.api.http.HttpRequest

public class HttpRequest extends Object
  • Konstruktordetails

    • HttpRequest

      public HttpRequest(String url, String method, Object body, Map<String,String> headers)
      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

      public HttpRequest(String url)
  • 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

      public String getUrl()
    • getMethod

      public String getMethod()
    • withMethod

      public HttpRequest withMethod(String method)
      Sets the method of the request.
      Parameter:
      method - The method to use.
      Gibt zurück:
      The HttpRequest.
    • getBody

      public Object getBody()
    • withBody

      public HttpRequest withBody(Object body)
      Sets the body of the request.
      Parameter:
      body - The body of the request.
      Gibt zurück:
      The HttpRequest.
    • getHeaders

      public Map<String,String> getHeaders()
    • withHeaders

      public HttpRequest withHeaders(Map<String,String> headers)
      Sets the headers of the request.
      Parameter:
      headers - The headers of the request.
      Gibt zurück:
      The HttpRequest.
    • withHeader

      public HttpRequest withHeader(String key, String value)
      Adds a header to the request.
      Parameter:
      key - The key of the header.
      value - The value of the header.
      Gibt zurück:
      The HttpRequest.
    • getTimeout

      public Duration getTimeout()
    • withTimeout

      public HttpRequest withTimeout(Duration timeout)
      Sets the timeout of the request.
      Parameter:
      timeout - The timeout of the request.
      Gibt zurück:
      The HttpRequest.