Class SimpleClient

java.lang.Object
io.github.parthappm.http.client.SimpleClient

public class SimpleClient extends Object
A class that contains all static methods to create an object of Client class by parsing the provided URL. The methods in this class does not make the request, to make the request, request() method of the returned object needs to be called.
  • Method Details

    • get

      public static Client get(String url) throws MalformedURLException
      Builds a get request from the provided URL, but does not make the request.
      Parameters:
      url - The URL to which the request is made
      Returns:
      An object of Client class
      Throws:
      MalformedURLException - if the URL passed is not a valid URL
    • post

      public static Client post(String url, byte[] body) throws MalformedURLException
      Builds a post request from the provided URL and request body, but does not make the request.
      Parameters:
      url - The URL to which the request is made
      body - The data to be sent as request body
      Returns:
      An object of Client class
      Throws:
      MalformedURLException - if the URL passed is not a valid URL
    • request

      public static Client request(String method, String url) throws MalformedURLException
      Builds an HTTP request for the mentioned HTTP method from the provided URL, but does not make the request.
      Parameters:
      method - The HTTP method to be used or the type of request i.e. GET, POST, PUT, DELETE, etc.
      url - The URL to which the request is made
      Returns:
      An object of Client class
      Throws:
      MalformedURLException - if the URL passed is not a valid URL