Class HttpUtils

java.lang.Object
org.hisp.dhis.util.HttpUtils

public class HttpUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Returns the string representing the given URI.
    static URI
    build(org.apache.hc.core5.net.URIBuilder uriBuilder)
    Builds on URI without throwing checked exceptions.
    static String
    getUriAsString(org.apache.hc.core5.http.message.BasicHttpRequest request)
    Returns the string representing the URI the given HTTP request.
    static <T extends org.apache.hc.client5.http.classic.methods.HttpUriRequestBase>
    T
    withAuth(T request, Dhis2Config config)
    Adds a HTTP header for authentication based on the Authentication of the given Dhis2Config.

    Methods inherited from class java.lang.Object

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

    • HttpUtils

      public HttpUtils()
  • Method Details

    • withAuth

      public static <T extends org.apache.hc.client5.http.classic.methods.HttpUriRequestBase> T withAuth(T request, Dhis2Config config)
      Adds a HTTP header for authentication based on the Authentication of the given Dhis2Config.
      Type Parameters:
      T - the request class type.
      Parameters:
      request - the HttpUriRequestBase.
      config - the Dhis2Config.
      Returns:
      the request object.
    • build

      public static URI build(org.apache.hc.core5.net.URIBuilder uriBuilder)
      Builds on URI without throwing checked exceptions.
      Parameters:
      uriBuilder - the URIBuilder.
      Returns:
      a URI.
    • asString

      public static String asString(URI uri)
      Returns the string representing the given URI. The URI is decoded.
      Parameters:
      uri - the URI.
      Returns:
      a URI string.
    • getUriAsString

      public static String getUriAsString(org.apache.hc.core5.http.message.BasicHttpRequest request)
      Returns the string representing the URI the given HTTP request. The URI is decoded.
      Parameters:
      request - the BasicHttpRequest.
      Returns:
      a URI string.