Class StandardInternetAccess

  • All Implemented Interfaces:
    InternetAccess

    public class StandardInternetAccess
    extends java.lang.Object
    implements InternetAccess
    Sends HTTP requests using the HTTP client included as part of the Java standard library. It also provides web socket support through the Java-WebSocket library.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      WebSocketConnection connectWebSocket​(java.lang.String uri)
      Connects to the web socket located at the specified URI.
      nl.colorize.util.Promise<java.lang.String> get​(java.lang.String url, nl.colorize.util.http.Headers headers)
      Sends a HTTP GET request to the specified URL.
      boolean isWebSocketSupported()  
      nl.colorize.util.Promise<java.lang.String> post​(java.lang.String url, nl.colorize.util.http.Headers headers, nl.colorize.util.http.PostData body)
      Sends a HTTP POST request to the specified URL.
      nl.colorize.util.Promise<java.lang.String> send​(nl.colorize.util.http.Method method, java.lang.String url, nl.colorize.util.http.Headers headers, nl.colorize.util.http.PostData body)  
      • Methods inherited from class java.lang.Object

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

      • StandardInternetAccess

        public StandardInternetAccess()
    • Method Detail

      • get

        public nl.colorize.util.Promise<java.lang.String> get​(java.lang.String url,
                                                              nl.colorize.util.http.Headers headers)
        Description copied from interface: InternetAccess
        Sends a HTTP GET request to the specified URL.
        Specified by:
        get in interface InternetAccess
        Returns:
        A Promise that can be used to process the response once it has been received.
      • post

        public nl.colorize.util.Promise<java.lang.String> post​(java.lang.String url,
                                                               nl.colorize.util.http.Headers headers,
                                                               nl.colorize.util.http.PostData body)
        Description copied from interface: InternetAccess
        Sends a HTTP POST request to the specified URL. The request body will be encoded using the application/x-www-form-urlencoded content type.
        Specified by:
        post in interface InternetAccess
        Returns:
        A Promise that can be used to process the response once it has been received.
      • send

        public nl.colorize.util.Promise<java.lang.String> send​(nl.colorize.util.http.Method method,
                                                               java.lang.String url,
                                                               nl.colorize.util.http.Headers headers,
                                                               nl.colorize.util.http.PostData body)
      • connectWebSocket

        public WebSocketConnection connectWebSocket​(java.lang.String uri)
        Description copied from interface: InternetAccess
        Connects to the web socket located at the specified URI. Note that some platforms may only allow the secure web socket protocol (i.e. "wss://").
        Specified by:
        connectWebSocket in interface InternetAccess