Package play.mvc

Class Http.Response

java.lang.Object
play.mvc.Http.Response
Enclosing class:
Http

public static class Http.Response extends Object
  • Field Details

  • Constructor Details

    • Response

      public Response()
  • Method Details

    • current

      @Deprecated public static Http.Response current()
      Deprecated.
    • setCurrent

      @Deprecated public static void setCurrent(Http.Response response)
      Deprecated.
    • removeCurrent

      public static void removeCurrent()
    • getHeader

      public @Nullable String getHeader(@NonNull String name)
      Get a response header
      Parameters:
      name - Header name case-insensitive
      Returns:
      the header value as a String
    • setHeader

      public void setHeader(String name, String value)
    • setContentTypeIfNotSet

      public void setContentTypeIfNotSet(String contentType)
    • setCookie

      public void setCookie(String name, String value)
    • removeCookie

      public void removeCookie(String name)
    • removeCookie

      public void removeCookie(String name, String path)
    • setCookie

      public void setCookie(String name, String value, String duration)
      Set a new cookie that will expire in (current) + duration
      Parameters:
      duration - the cookie duration (Ex: "3d")
    • setCookie

      public void setCookie(String name, String value, String domain, String path, Integer maxAge, boolean secure)
    • setCookie

      public void setCookie(String name, String value, String domain, String path, Integer maxAge, boolean secure, boolean httpOnly)
    • cacheFor

      public void cacheFor(String duration)
      Add a cache-control header
      Parameters:
      duration - Ex: 3h
    • cacheFor

      public void cacheFor(String eTag, String duration, long lastModified)
      Add cache-control headers
      Parameters:
      eTag - the Etag value
      duration - the cache duration (Ex: 3h)
      lastModified - The last modified date
    • accessControl

      public void accessControl(String allowOrigin)
      Add headers to allow cross-domain requests. Be careful, a lot of browsers don't support these features and will ignore the headers. Refer to the browsers' documentation to know what versions support them.
      Parameters:
      allowOrigin - a comma separated list of domains allowed to perform the x-domain call, or "*" for all.
    • accessControl

      public void accessControl(String allowOrigin, boolean allowCredentials)
      Add headers to allow cross-domain requests. Be careful, a lot of browsers don't support these features and will ignore the headers. Refer to the browsers' documentation to know what versions support them.
      Parameters:
      allowOrigin - a comma separated list of domains allowed to perform the x-domain call, or "*" for all.
      allowCredentials - Let the browser send the cookies when doing an x-domain request. Only respected by the browser if allowOrigin != "*"
    • accessControl

      public void accessControl(String allowOrigin, String allowMethods, boolean allowCredentials)
      Add headers to allow cross-domain requests. Be careful, a lot of browsers don't support these features and will ignore the headers. Refer to the browsers' documentation to know what versions support them.
      Parameters:
      allowOrigin - a comma separated list of domains allowed to perform the x-domain call, or "*" for all.
      allowMethods - a comma separated list of HTTP methods allowed, or null for all.
      allowCredentials - Let the browser send the cookies when doing an x-domain request. Only respected by the browser if allowOrigin != "*"
    • print

      public void print(String text)
    • writeChunk

      public void writeChunk(Object o)
    • onWriteChunk

      public void onWriteChunk(Consumer<Object> handler)