Interface HttpResponse


public interface HttpResponse

Represents an out coming HTTP response.

Instances of this class can be obtained from KeycloakContext.getHttpResponse().

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addHeader(String name, String value)
    Add a value to the current list of values for the header with the given name.
    int
    Gets the current status code.
    void
    setCookieIfAbsent(jakarta.ws.rs.core.NewCookie cookie)
    Sets a new cookie only if not yet set.
    void
    setHeader(String name, String value)
    Set a header.
    void
    setStatus(int statusCode)
    Sets a status code.
  • Method Details

    • getStatus

      int getStatus()
      Gets the current status code.

      Warning: this will typically not be the actual status returned as that will be managed by JAX-RS based upon the return value or exception from the endpoint method.

    • setStatus

      void setStatus(int statusCode)
      Sets a status code.

      Warning: this value is silently overwritten by the JAX-RS runtime based upon the return value or exception from the endpoint method. Please use a JAX-RS compatible way of setting the status instead.

      Parameters:
      statusCode - the status code
    • addHeader

      void addHeader(String name, String value)
      Add a value to the current list of values for the header with the given name.
      Parameters:
      name - the header name
      value - the header value
    • setHeader

      void setHeader(String name, String value)
      Set a header. Any existing values will be replaced.
      Parameters:
      name - the header name
      value - the header value
    • setCookieIfAbsent

      void setCookieIfAbsent(jakarta.ws.rs.core.NewCookie cookie)
      Sets a new cookie only if not yet set.
      Parameters:
      cookie - the cookie