Class HttpRequestHelper


  • public class HttpRequestHelper
    extends java.lang.Object
    Wrapper created to abstract HTTP requests.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_TIMEOUT  
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpRequestHelper​(io.didomi.sdk.user.UserAgentRepository userAgentRepository)  
    • Constructor Detail

      • HttpRequestHelper

        public HttpRequestHelper​(io.didomi.sdk.user.UserAgentRepository userAgentRepository)
    • Method Detail

      • doGetCall

        public void doGetCall​(java.lang.String urlString,
                              HttpResponseStringListener listener,
                              int timeout,
                              long ifModifiedSince)
        Method used to do GET calls
        Parameters:
        urlString - URL to call
        listener - listener receiving request response
        timeout - request timeout
        ifModifiedSince - Timestamp (in ms) for the If-Modified-Since header, or 0. If the file was not modified on server, onSuccess will be called with an empty response.
      • doGetCall

        public void doGetCall​(java.lang.String urlString,
                              HttpResponseJSONListener listener)
        Method used to do GET calls and parse the response as JSON
        Parameters:
        urlString - URL to call
        listener - listener receiving request response
      • doPostCall

        public void doPostCall​(java.lang.String urlString,
                               java.lang.String content,
                               HttpResponseStringListener listener)
        Method used to do POST calls
        Parameters:
        urlString - URL to call
        content - body content (mandatory)
        listener - listener receiving request response
      • doPostCall

        public void doPostCall​(java.lang.String urlString,
                               java.lang.String content,
                               HttpResponseStringListener listener,
                               int timeout)
        Method used to do POST calls with custom timeout
        Parameters:
        urlString - URL to call
        content - body content (mandatory)
        listener - listener receiving request response
        timeout - request timeout
      • doPostCall

        public void doPostCall​(java.lang.String urlString,
                               java.lang.String content,
                               HttpResponseJSONListener listener)
        Method used to do POST calls and parse the response as JSON
        Parameters:
        urlString - URL to call
        content - body content (mandatory)
        listener - listener receiving request response