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 Responsedelegateprivate booleanredirected
-
Constructor Summary
Constructors Modifier Constructor Description privateResponseWrapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringbody()returns the bodyvoidbody(java.lang.String body)Sets the bodyvoidcookie(java.lang.String name, java.lang.String value)Adds not persistent cookie to the response.voidcookie(java.lang.String name, java.lang.String value, int maxAge)Adds cookie to the response.voidcookie(java.lang.String name, java.lang.String value, int maxAge, boolean secured)Adds cookie to the response.voidcookie(java.lang.String path, java.lang.String name, java.lang.String value, int maxAge, boolean secured)Adds cookie to the response.voidcookie(java.lang.String path, java.lang.String name, java.lang.String value, int maxAge, boolean secured, boolean httpOnly)Adds cookie to the response.voidcookie(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 ResponseWrappercreate()booleanequals(java.lang.Object obj)(package private) ResponsegetDelegate()inthashCode()voidheader(java.lang.String header, java.lang.String value)Adds/Sets a response header(package private) booleanisRedirected()javax.servlet.http.HttpServletResponseraw()voidredirect(java.lang.String location)Trigger a browser redirectvoidredirect(java.lang.String location, int httpStatusCode)Trigger a browser redirect with specific http 3XX status code.voidremoveCookie(java.lang.String name)Removes the cookie.voidremoveCookie(java.lang.String path, java.lang.String name)Removes the cookie with given path and name.voidsetDelegate(Response delegate)intstatus()Returns the status codevoidstatus(int statusCode)Sets the status code for thejava.lang.StringtoString()java.lang.Stringtype()Returns the content typevoidtype(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:ResponseSets the status code for the
-
status
public int status()
Description copied from class:ResponseReturns the status code
-
body
public void body(java.lang.String body)
Description copied from class:ResponseSets the body
-
body
public java.lang.String body()
Description copied from class:Responsereturns the body
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
raw
public javax.servlet.http.HttpServletResponse raw()
-
redirect
public void redirect(java.lang.String location)
Description copied from class:ResponseTrigger a browser redirect
-
redirect
public void redirect(java.lang.String location, int httpStatusCode)Description copied from class:ResponseTrigger 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:ResponseAdds/Sets a response header
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
type
public void type(java.lang.String contentType)
Description copied from class:ResponseSets the content type for the response
-
type
public java.lang.String type()
Description copied from class:ResponseReturns the content type
-
cookie
public void cookie(java.lang.String name, java.lang.String value)Description copied from class:ResponseAdds 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:ResponseAdds 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:ResponseAdds 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:ResponseAdds 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:ResponseAdds cookie to the response. Can be invoked multiple times to insert more than one cookie.- Overrides:
cookiein 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:ResponseAdds cookie to the response. Can be invoked multiple times to insert more than one cookie.- Overrides:
cookiein 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:ResponseRemoves the cookie.- Overrides:
removeCookiein classResponse- Parameters:
name- name of the cookie
-
removeCookie
public void removeCookie(java.lang.String path, java.lang.String name)Description copied from class:ResponseRemoves the cookie with given path and name.- Overrides:
removeCookiein classResponse- Parameters:
path- path of the cookiename- name of the cookie
-
-