Module aeonics.core
Package aeonics.util

Class Http


  • public class Http
    extends java.lang.Object
    Simple http request fetcher. The result is returned as data. If the response mime type was application/json, then it is automatically decoded.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Http.Error
      Represents an HTTP Error code with possibly a body response.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int CONNECT_TIMEOUT
      The maximum number of milliseconds to wait before the connection is established.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Data get​(java.lang.String url)
      Fetches the specified resource using GET
      static Data get​(java.lang.String url, Data queryString)
      Fetches the specified resource using GET
      static Data get​(java.lang.String url, Data queryString, Data headers)
      Fetches the specified resource using GET
      static Data get​(java.lang.String url, Data queryString, Data headers, java.lang.String method)
      Fetches the specified resource using the provided method and include the parameters in the query string of the request
      static Data get​(java.lang.String url, Data queryString, Data headers, java.lang.String method, int timeout)
      Fetches the specified resource using the provided method and include the parameters in the query string of the request
      static Data post​(java.lang.String url)
      Fetches the specified resource using POST
      static Data post​(java.lang.String url, Data body)
      Fetches the specified resource using POST
      static Data post​(java.lang.String url, Data body, Data headers)
      Fetches the specified resource using POST
      static Data post​(java.lang.String url, Data body, Data headers, java.lang.String method)
      Fetches the specified resource using the provided method and include the parameters in the body of the request
      static Data post​(java.lang.String url, Data body, Data headers, java.lang.String method, int timeout)
      Fetches the specified resource using the provided method and include the parameters in the body of the request
      • Methods inherited from class java.lang.Object

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

      • CONNECT_TIMEOUT

        public static int CONNECT_TIMEOUT
        The maximum number of milliseconds to wait before the connection is established. This does not affect the response time once the connection is established.
    • Method Detail

      • post

        public static Data post​(java.lang.String url)
        Fetches the specified resource using POST
        Parameters:
        url - the url
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • post

        public static Data post​(java.lang.String url,
                                Data body)
        Fetches the specified resource using POST
        Parameters:
        url - the url
        body - the content to send in key/value pairs
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • post

        public static Data post​(java.lang.String url,
                                Data body,
                                Data headers)
        Fetches the specified resource using POST
        Parameters:
        url - the url
        body - the content to send in key/value pairs
        headers - the http request headers
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • post

        public static Data post​(java.lang.String url,
                                Data body,
                                Data headers,
                                java.lang.String method)
        Fetches the specified resource using the provided method and include the parameters in the body of the request
        Parameters:
        url - the url
        body - the content to send in key/value pairs
        headers - the http request headers
        method - the http method
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • post

        public static Data post​(java.lang.String url,
                                Data body,
                                Data headers,
                                java.lang.String method,
                                int timeout)
        Fetches the specified resource using the provided method and include the parameters in the body of the request
        Parameters:
        url - the url
        body - the content to send in key/value pairs
        headers - the http request headers
        method - the http method
        timeout - the request timeout in milliseconds. 0 means infinite.
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • get

        public static Data get​(java.lang.String url)
        Fetches the specified resource using GET
        Parameters:
        url - the url
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • get

        public static Data get​(java.lang.String url,
                               Data queryString)
        Fetches the specified resource using GET
        Parameters:
        url - the url
        queryString - the content to append to the url in key/value pairs
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • get

        public static Data get​(java.lang.String url,
                               Data queryString,
                               Data headers)
        Fetches the specified resource using GET
        Parameters:
        url - the url
        queryString - the content to append to the url in key/value pairs
        headers - the http request headers
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • get

        public static Data get​(java.lang.String url,
                               Data queryString,
                               Data headers,
                               java.lang.String method)
        Fetches the specified resource using the provided method and include the parameters in the query string of the request
        Parameters:
        url - the url
        queryString - the content to append to the url in key/value pairs
        headers - the http request headers
        method - the http method
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)
      • get

        public static Data get​(java.lang.String url,
                               Data queryString,
                               Data headers,
                               java.lang.String method,
                               int timeout)
        Fetches the specified resource using the provided method and include the parameters in the query string of the request
        Parameters:
        url - the url
        queryString - the content to append to the url in key/value pairs
        headers - the http request headers
        method - the http method
        timeout - the request timeout in milliseconds. 0 means infinite.
        Returns:
        the response
        Throws:
        Http.Error - if the remote endpoint returns an error (http code 400+)