Package org.swtpra1

Class HTTPSClient


  • public class HTTPSClient
    extends java.lang.Object
    HTTPSClient Responsible for executing the HTTPS methods. The article about HTTP: https://www.javaguides.net/2019/07/java-http-getpost-request-example.html The article about HTTPS: https://mkyong.com/java/java-https-client-httpsurlconnection-example/ The article about response headers: https://mkyong.com/java/how-to-get-http-response-header-in-java/
    • Constructor Summary

      Constructors 
      Constructor Description
      HTTPSClient()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static HTTPSResponse delete​(java.lang.String url)
      Sends a DELETE request.
      static HTTPSResponse delete​(java.lang.String url, int readTimeout)
      Sends a DELETE request.
      static HTTPSResponse get​(java.lang.String url)
      Sends a GET request.
      static HTTPSResponse get​(java.lang.String url, int readTimeout)
      Sends a GET request.
      static HTTPSResponse post​(java.lang.String url, java.lang.String postBody)
      Sends a post request.
      static HTTPSResponse post​(java.lang.String url, java.lang.String postBody, int readTimeout)
      Sends a post request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HTTPSClient

        public HTTPSClient()
    • Method Detail

      • get

        public static HTTPSResponse get​(java.lang.String url)
                                 throws java.io.IOException
        Sends a GET request.
        Parameters:
        url - The resource that shall be fetched.
        Throws:
        java.io.IOException - IOException.
      • get

        public static HTTPSResponse get​(java.lang.String url,
                                        int readTimeout)
                                 throws java.io.IOException
        Sends a GET request.
        Parameters:
        url - The resource that shall be fetched.
        readTimeout - The timeout in milliseconds for the read time of the input stream after the connection has been established.
        Returns:
        HTTPSResponse of request
        Throws:
        java.io.IOException - IOException.
      • delete

        public static HTTPSResponse delete​(java.lang.String url)
                                    throws java.io.IOException
        Sends a DELETE request.
        Parameters:
        url - The URL to which the request is sent.
        Returns:
        HTTPSResponse of request
        Throws:
        java.io.IOException - IOException.
      • delete

        public static HTTPSResponse delete​(java.lang.String url,
                                           int readTimeout)
                                    throws java.io.IOException
        Sends a DELETE request.
        Parameters:
        url - The URL to which the request is sent.
        readTimeout - The timeout in milliseconds for the read time of the input stream after the connection has been established.
        Returns:
        HTTPSResponse of request
        Throws:
        java.io.IOException - IOException.
      • post

        public static HTTPSResponse post​(java.lang.String url,
                                         java.lang.String postBody)
                                  throws java.io.IOException
        Sends a post request.
        Parameters:
        url - The endpoint to which the request posts.
        postBody - The Post body in application/x-www-form-urlencoded format.
        Returns:
        HTTPSResponse of request
        Throws:
        java.io.IOException - IOException.
      • post

        public static HTTPSResponse post​(java.lang.String url,
                                         java.lang.String postBody,
                                         int readTimeout)
                                  throws java.io.IOException
        Sends a post request.
        Parameters:
        url - The endpoint to which the request posts.
        postBody - The Post body in application/x-www-form-urlencoded format.
        readTimeout - The timeout in milliseconds for the read time of the input stream after the connection has been established.
        Returns:
        HTTPSResponse of request
        Throws:
        java.io.IOException - IOException.