Status

play.api.mvc.Results.Status
class Status(status: Int) extends Result

Generates default Result from a content type, headers and content.

Value parameters

status

the HTTP response status, e.g ‘200 OK’

Attributes

Graph
Supertypes
class Result
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def apply[C](content: C)(implicit writeable: Writeable[C]): Result

Set the result's content.

Set the result's content.

Value parameters

content

The content to send.

Attributes

def chunked[C](content: Source[C, _], contentType: Option[String])(implicit writeable: Writeable[C]): Result

Feed the content as the response, using chunked transfer encoding.

Feed the content as the response, using chunked transfer encoding.

Chunked transfer encoding is only supported for HTTP 1.1 clients. If the client is an HTTP 1.0 client, Play will instead return a 505 error code.

Chunked encoding allows the server to send a response where the content length is not known, or for potentially infinite streams, while still allowing the connection to be kept alive and reused for the next request.

Value parameters

content

Source providing the content to stream.

contentType

an optional content type.

Attributes

def chunked[C](content: Source[C, _], inline: Boolean, fileName: Option[String])(implicit writeable: Writeable[C], fileMimeTypes: FileMimeTypes): Result

Feed the content as the response, using chunked transfer encoding.

Feed the content as the response, using chunked transfer encoding.

Chunked transfer encoding is only supported for HTTP 1.1 clients. If the client is an HTTP 1.0 client, Play will instead return a 505 error code.

Chunked encoding allows the server to send a response where the content length is not known, or for potentially infinite streams, while still allowing the connection to be kept alive and reused for the next request.

Value parameters

content

Source providing the content to stream.

fileName

Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to the content-type of the implicit writeable if unknown.

inline

If the content should be rendered inline or as attachment.

Attributes

def sendEntity(entity: HttpEntity): Result

Send an HTTP entity with this status.

Send an HTTP entity with this status.

Value parameters

entity

The entity to send.

Attributes

def sendEntity(entity: HttpEntity, inline: Boolean, fileName: Option[String])(implicit fileMimeTypes: FileMimeTypes): Result

Send an HTTP entity with this status.

Send an HTTP entity with this status.

Value parameters

entity

The entity to send.

fileName

Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to application/octet-stream if unknown.

inline

If the content should be rendered inline or as attachment.

Attributes

def sendFile(content: File, inline: Boolean, fileName: File => Option[String], onClose: () => Unit)(implicit ec: ExecutionContext, fileMimeTypes: FileMimeTypes): Result

Send a file.

Send a file.

Value parameters

content

The file to send.

fileName

Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to application/octet-stream if unknown.

inline

Use Content-Disposition inline or attachment.

onClose

Useful in order to perform cleanup operations (e.g. deleting a temporary file generated for a download).

Attributes

def sendPath(content: Path, inline: Boolean, fileName: Path => Option[String], onClose: () => Unit)(implicit ec: ExecutionContext, fileMimeTypes: FileMimeTypes): Result

Send a path.

Send a path.

Value parameters

content

The path to send.

fileName

Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to application/octet-stream if unknown.

inline

Use Content-Disposition inline or attachment.

onClose

Useful in order to perform cleanup operations (e.g. deleting a temporary file generated for a download).

Attributes

def sendResource(resource: String, classLoader: ClassLoader, inline: Boolean, fileName: String => Option[String], onClose: () => Unit)(implicit ec: ExecutionContext, fileMimeTypes: FileMimeTypes): Result

Send the given resource from the given classloader.

Send the given resource from the given classloader.

Value parameters

classLoader

The classloader to load it from, defaults to the classloader for this class.

fileName

Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to application/octet-stream if unknown.

inline

Whether it should be served as an inline file, or as an attachment.

onClose

Useful in order to perform cleanup operations (e.g. deleting a temporary file generated for a download).

resource

The path of the resource to load.

Attributes

def streamed[C](content: Source[C, _], contentLength: Option[Long], contentType: Option[String])(implicit writeable: Writeable[C]): Result

Feed the content as the response, using a streamed entity.

Feed the content as the response, using a streamed entity.

It will use the given Content-Type, but if is not present, then it fallsback to use the Writeable contentType.

Value parameters

content

Source providing the content to stream.

contentLength

an optional content length.

contentType

an optional content type.

Attributes

def streamed[C](content: Source[C, _], contentLength: Option[Long], inline: Boolean, fileName: Option[String])(implicit writeable: Writeable[C], fileMimeTypes: FileMimeTypes): Result

Feed the content as the response, using a streamed entity.

Feed the content as the response, using a streamed entity.

It will use the given Content-Type, but if is not present, then it fallsback to use the Writeable contentType.

Value parameters

content

Source providing the content to stream.

contentLength

an optional content length.

fileName

Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to the content-type of the implicit writeable if unknown.

inline

If the content should be rendered inline or as attachment.

Attributes

Inherited methods

def addAttr[A](key: TypedKey[A], value: A): Result

Create a new versions of this object with the given attribute attached to it.

Create a new versions of this object with the given attribute attached to it.

Type parameters

A

The type of value.

Value parameters

key

The new attribute key.

value

The attribute value.

Attributes

Returns

The new version of this object with the new attribute.

Inherited from:
Result
def addAttrs(entries: TypedEntry[_]*): Result

Create a new versions of this object with the given attributes attached to it.

Create a new versions of this object with the given attributes attached to it.

Value parameters

entries

The new attributes.

Attributes

Returns

The new version of this object with the new attributes.

Inherited from:
Result
def addAttrs(e1: TypedEntry[_], e2: TypedEntry[_], e3: TypedEntry[_]): Result

Create a new versions of this object with the given attributes attached to it.

Create a new versions of this object with the given attributes attached to it.

Value parameters

e1

The first new attribute.

e2

The second new attribute.

e3

The third new attribute.

Attributes

Returns

The new version of this object with the new attributes.

Inherited from:
Result
def addAttrs(e1: TypedEntry[_], e2: TypedEntry[_]): Result

Create a new versions of this object with the given attributes attached to it.

Create a new versions of this object with the given attributes attached to it.

Value parameters

e1

The first new attribute.

e2

The second new attribute.

Attributes

Returns

The new version of this object with the new attributes.

Inherited from:
Result
def addAttrs(e1: TypedEntry[_]): Result

Create a new versions of this object with the given attribute attached to it.

Create a new versions of this object with the given attribute attached to it.

Value parameters

e1

The new attribute.

Attributes

Returns

The new version of this object with the new attribute.

Inherited from:
Result
def addingToSession(values: (String, String)*)(implicit request: RequestHeader): Result

Example:

Example:

 Ok.addingToSession("foo" -> "bar").addingToSession("baz" -> "bah")

Value parameters

request

Current request

values

(key -> value) pairs to add to this result’s session

Attributes

Returns

A copy of this result with values added to its session scope.

Inherited from:
Result
def as(contentType: String): Result

Changes the result content type.

Changes the result content type.

For example:

Ok("<text>Hello world</text>").as("application/xml")

Value parameters

contentType

the new content type.

Attributes

Returns

the new result

Inherited from:
Result
def asJava: Result

Convert this result to a Java result.

Convert this result to a Java result.

Attributes

Inherited from:
Result
def bakeCookies(cookieHeaderEncoding: CookieHeaderEncoding, sessionBaker: CookieBaker[Session], flashBaker: CookieBaker[Flash], requestHasFlash: Boolean): Result

Encode the cookies into the Set-Cookie header. The session is always baked first, followed by the flash cookie, followed by all the other cookies in order.

Encode the cookies into the Set-Cookie header. The session is always baked first, followed by the flash cookie, followed by all the other cookies in order.

Attributes

Inherited from:
Result

Discards cookies along this result.

Discards cookies along this result.

For example:

Redirect(routes.Application.index()).discardingCookies(DiscardingCookie("theme"))

Value parameters

cookies

the cookies to discard along to this result

Attributes

Returns

the new result

Inherited from:
Result

Discards headers to this result.

Discards headers to this result.

For example:

Ok("Hello world").discardingHeader(ETAG)

Value parameters

name

the header to discard from this result.

Attributes

Returns

the new result

Inherited from:
Result
def flashing(values: (String, String)*): Result

Adds values to the flash scope for this result.

Adds values to the flash scope for this result.

For example:

Redirect(routes.Application.index()).flashing("success" -> "Done!")

Value parameters

values

the flash values to set with this result

Attributes

Returns

the new result

Inherited from:
Result
def flashing(flash: Flash): Result

Adds values to the flash scope for this result.

Adds values to the flash scope for this result.

For example:

Redirect(routes.Application.index()).flashing(flash + ("success" -> "Done!"))

Value parameters

flash

the flash scope to set with this result

Attributes

Returns

the new result

Inherited from:
Result

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product
def removeAttr(key: TypedKey[_]): Result

Create a new versions of this object with the given attribute removed.

Create a new versions of this object with the given attribute removed.

Value parameters

key

The key of the attribute to remove.

Attributes

Returns

The new version of this object with the attribute removed.

Inherited from:
Result
def removingFromSession(keys: String*)(implicit request: RequestHeader): Result

Example:

Example:

 Ok.removingFromSession("foo")

Value parameters

keys

Keys to remove from session

request

Current request

Attributes

Returns

A copy of this result with keys removed from its session scope.

Inherited from:
Result
def session(implicit request: RequestHeader): Session

Value parameters

request

Current request

Attributes

Returns

The session carried by this result. Reads the request’s session if this result does not modify the session.

Inherited from:
Result
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Result -> Any
Inherited from:
Result
def withAttrs(newAttrs: TypedMap): Result

Create a new version of this object with the given attributes attached to it. This replaces any existing attributes.

Create a new version of this object with the given attributes attached to it. This replaces any existing attributes.

Value parameters

newAttrs

The new attributes to add.

Attributes

Returns

The new version of this object with the attributes attached.

Inherited from:
Result
def withCookies(cookies: Cookie*): Result

Adds cookies to this result. If the result already contains cookies then cookies with the same name in the new list will override existing ones.

Adds cookies to this result. If the result already contains cookies then cookies with the same name in the new list will override existing ones.

For example:

Redirect(routes.Application.index()).withCookies(Cookie("theme", "blue"))

Value parameters

cookies

the cookies to add to this result

Attributes

Returns

the new result

Inherited from:
Result
def withDateHeaders(headers: (String, ZonedDateTime)*): Result

Add a header with a DateTime formatted using the default http date format

Add a header with a DateTime formatted using the default http date format

Value parameters

headers

the headers with a DateTime to add to this result.

Attributes

Returns

the new result.

Inherited from:
Result
def withHeaders(headers: (String, String)*): Result

Adds headers to this result.

Adds headers to this result.

For example:

Ok("Hello world").withHeaders(ETAG -> "0")

Value parameters

headers

the headers to add to this result.

Attributes

Returns

the new result

Inherited from:
Result

Discards the existing session for this result.

Discards the existing session for this result.

For example:

Redirect(routes.Application.index()).withNewSession

Attributes

Returns

the new result

Inherited from:
Result
def withSession(session: (String, String)*): Result

Sets a new session for this result, discarding the existing session.

Sets a new session for this result, discarding the existing session.

For example:

Redirect(routes.Application.index()).withSession("saidHello" -> "yes")

Value parameters

session

the session to set with this result

Attributes

Returns

the new result

Inherited from:
Result
def withSession(session: Session): Result

Sets a new session for this result.

Sets a new session for this result.

For example:

Redirect(routes.Application.index()).withSession(session + ("saidHello" -> "true"))

Value parameters

session

the session to set with this result

Attributes

Returns

the new result

Inherited from:
Result