Class HttpRequest

java.lang.Object
org.codelibs.saml2.core.http.HttpRequest

public final class HttpRequest extends Object
Framework-agnostic representation of an HTTP request.
Since:
2.0.0
  • Field Details

  • Constructor Details

    • HttpRequest

      @Deprecated public HttpRequest(String requestURL)
      Deprecated.
      Not providing a queryString can cause HTTP Redirect binding to fail.
      Creates a new HttpRequest.
      Parameters:
      requestURL - the request URL (up to but not including query parameters)
    • HttpRequest

      public HttpRequest(String requestURL, String queryString)
      Creates a new HttpRequest.
      Parameters:
      requestURL - the request URL (up to but not including query parameters)
      queryString - string that is contained in the request URL after the path
    • HttpRequest

      @Deprecated public HttpRequest(String requestURL, Map<String,List<String>> parameters)
      Deprecated.
      Not providing a queryString can cause HTTP Redirect binding to fail.
      Creates a new HttpRequest.
      Parameters:
      requestURL - the request URL (up to but not including query parameters)
      parameters - the request query parameters
    • HttpRequest

      public HttpRequest(String requestURL, Map<String,List<String>> parameters, String queryString)
      Creates a new HttpRequest.
      Parameters:
      requestURL - the request URL (up to but not including query parameters)
      parameters - the request query parameters
      queryString - string that is contained in the request URL after the path
  • Method Details

    • addParameter

      public HttpRequest addParameter(String name, String value)
      Parameters:
      name - the query parameter name
      value - the query parameter value
      Returns:
      a new HttpRequest with the given query parameter added
    • removeParameter

      public HttpRequest removeParameter(String name)
      Parameters:
      name - the query parameter name
      Returns:
      a new HttpRequest with the given query parameter removed
    • getRequestURL

      public String getRequestURL()
      The URL the client used to make the request. Includes a protocol, server name, port number, and server path, but not the query string parameters.
      Returns:
      the request URL
    • getParameter

      public String getParameter(String name)
      Parameters:
      name - the query parameter name
      Returns:
      the first value for the parameter, or null
    • getParameters

      public List<String> getParameters(String name)
      Parameters:
      name - the query parameter name
      Returns:
      a List containing all values for the parameter
    • getParameters

      public Map<String,List<String>> getParameters()
      Returns:
      a map of all query parameters
    • getEncodedParameter

      public String getEncodedParameter(String name)
      Return an url encoded get parameter value Prefer to extract the original encoded value directly from queryString since url encoding is not canonical.
      Parameters:
      name -
      Returns:
      the first value for the parameter, or null
    • getEncodedParameter

      public String getEncodedParameter(String name, String defaultValue)
      Return an url encoded get parameter value Prefer to extract the original encoded value directly from queryString since url encoding is not canonical.
      Parameters:
      name -
      defaultValue -
      Returns:
      the first value for the parameter, or url encoded default value
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object