Package spark.http.matching
Class ResponseWrapper
- java.lang.Object
-
- spark.Response
-
- spark.http.matching.ResponseWrapper
-
class ResponseWrapper extends Response
-
-
Field Summary
Fields Modifier and Type Field Description private Response
delegate
private boolean
redirected
-
Constructor Summary
Constructors Modifier Constructor Description private
ResponseWrapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
body()
returns the bodyvoid
body(java.lang.String body)
Sets the bodyvoid
cookie(java.lang.String name, java.lang.String value)
Adds not persistent cookie to the response.void
cookie(java.lang.String name, java.lang.String value, int maxAge)
Adds cookie to the response.void
cookie(java.lang.String name, java.lang.String value, int maxAge, boolean secured)
Adds cookie to the response.void
cookie(java.lang.String path, java.lang.String name, java.lang.String value, int maxAge, boolean secured)
Adds cookie to the response.void
cookie(java.lang.String path, java.lang.String name, java.lang.String value, int maxAge, boolean secured, boolean httpOnly)
Adds cookie to the response.void
cookie(java.lang.String domain, java.lang.String path, java.lang.String name, java.lang.String value, int maxAge, boolean secured, boolean httpOnly)
Adds cookie to the response.(package private) static ResponseWrapper
create()
boolean
equals(java.lang.Object obj)
(package private) Response
getDelegate()
int
hashCode()
void
header(java.lang.String header, java.lang.String value)
Adds/Sets a response header(package private) boolean
isRedirected()
javax.servlet.http.HttpServletResponse
raw()
void
redirect(java.lang.String location)
Trigger a browser redirectvoid
redirect(java.lang.String location, int httpStatusCode)
Trigger a browser redirect with specific http 3XX status code.void
removeCookie(java.lang.String name)
Removes the cookie.void
removeCookie(java.lang.String path, java.lang.String name)
Removes the cookie with given path and name.void
setDelegate(Response delegate)
int
status()
Returns the status codevoid
status(int statusCode)
Sets the status code for thejava.lang.String
toString()
java.lang.String
type()
Returns the content typevoid
type(java.lang.String contentType)
Sets the content type for the response
-
-
-
Field Detail
-
delegate
private Response delegate
-
redirected
private boolean redirected
-
-
Method Detail
-
create
static ResponseWrapper create()
-
setDelegate
public void setDelegate(Response delegate)
-
getDelegate
Response getDelegate()
-
status
public void status(int statusCode)
Description copied from class:Response
Sets the status code for the
-
status
public int status()
Description copied from class:Response
Returns the status code
-
body
public void body(java.lang.String body)
Description copied from class:Response
Sets the body
-
body
public java.lang.String body()
Description copied from class:Response
returns the body
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
raw
public javax.servlet.http.HttpServletResponse raw()
-
redirect
public void redirect(java.lang.String location)
Description copied from class:Response
Trigger a browser redirect
-
redirect
public void redirect(java.lang.String location, int httpStatusCode)
Description copied from class:Response
Trigger a browser redirect with specific http 3XX status code.
-
isRedirected
boolean isRedirected()
- Returns:
- true if redirected has been done
-
header
public void header(java.lang.String header, java.lang.String value)
Description copied from class:Response
Adds/Sets a response header
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
type
public void type(java.lang.String contentType)
Description copied from class:Response
Sets the content type for the response
-
type
public java.lang.String type()
Description copied from class:Response
Returns the content type
-
cookie
public void cookie(java.lang.String name, java.lang.String value)
Description copied from class:Response
Adds not persistent cookie to the response. Can be invoked multiple times to insert more than one cookie.
-
cookie
public void cookie(java.lang.String name, java.lang.String value, int maxAge)
Description copied from class:Response
Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.
-
cookie
public void cookie(java.lang.String name, java.lang.String value, int maxAge, boolean secured)
Description copied from class:Response
Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.
-
cookie
public void cookie(java.lang.String path, java.lang.String name, java.lang.String value, int maxAge, boolean secured)
Description copied from class:Response
Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.
-
cookie
public void cookie(java.lang.String path, java.lang.String name, java.lang.String value, int maxAge, boolean secured, boolean httpOnly)
Description copied from class:Response
Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.- Overrides:
cookie
in classResponse
- Parameters:
path
- path of the cookiename
- name of the cookievalue
- value of the cookiemaxAge
- max age of the cookie in seconds (negative for the not persistent cookie, zero - deletes the cookie)secured
- if true : cookie will be securedhttpOnly
- if true: cookie will be marked as http only
-
cookie
public void cookie(java.lang.String domain, java.lang.String path, java.lang.String name, java.lang.String value, int maxAge, boolean secured, boolean httpOnly)
Description copied from class:Response
Adds cookie to the response. Can be invoked multiple times to insert more than one cookie.- Overrides:
cookie
in classResponse
- Parameters:
domain
- domain of the cookiepath
- path of the cookiename
- name of the cookievalue
- value of the cookiemaxAge
- max age of the cookie in seconds (negative for the not persistent cookie, zero - deletes the cookie)secured
- if true : cookie will be securedhttpOnly
- if true: cookie will be marked as http only
-
removeCookie
public void removeCookie(java.lang.String name)
Description copied from class:Response
Removes the cookie.- Overrides:
removeCookie
in classResponse
- Parameters:
name
- name of the cookie
-
removeCookie
public void removeCookie(java.lang.String path, java.lang.String name)
Description copied from class:Response
Removes the cookie with given path and name.- Overrides:
removeCookie
in classResponse
- Parameters:
path
- path of the cookiename
- name of the cookie
-
-