Class SpincastResponseRequestContextAddon<R extends RequestContext<?>>
- All Implemented Interfaces:
ResponseRequestContextAddon<R>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final booleanprotected static final org.slf4j.LoggerFields inherited from interface org.spincast.core.exchange.ResponseRequestContextAddon
RESOURCE_TO_PUSH_PLACEHOLDERS_CACHE_BUSTER -
Constructor Summary
ConstructorsConstructorDescriptionSpincastResponseRequestContextAddon(R requestContext, Server server, JsonManager jsonManager, XmlManager xmlManager, SpincastConfig spincastConfig, SpincastUtils spincastUtils, ETagFactory etagFactory, FlashMessagesHolder flashMessagesHolder, FlashMessageFactory flashMessageFactory, CookieFactory cookieFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAlert(AlertLevel alertType, String alertText) Adds an Alert that is, in general, displayed at the top of the page to show the user an Error, a Warning or a confirmation message.protected voidprotected voidaddCookieSafe(String name, String value, Integer nbrSecondsToLive) voidAdds aFormobject to the response's model and links its validation messages to the default "validation" root element.voidAdds aFormobject to the response's model and links its validation messages to the specified validation element.addHeaderValue(String name, String value) Adds a value to a response header.addHeaderValues(String name, List<String> values) Adds a list of values to a response header.protected AlertcreateAlert(AlertLevel alertType, String alertText) createCookie(String name) Creates a cookie using the given name (nullvalue).voidDeletes all cookies! Not only the new cookies that have been added to the response, but also the cookies that have been received in the request!voiddeleteCookie(String name) Deletes a cookie.voidend()Flushes everything and closes the response.voidflush()Flushes the current response.voidflush(boolean close) Flushes the current response.protected ByteArrayOutputStreamThe charset to use to convert characters to bytes.The currentContent-Typesent or to be send.getCookieAdded(String name) Gets a cookie already added to the response, by its name.protected CookieFactoryGets the cookies already added to the response as a Map, using their names as the keys.protected ETagFactoryprotected Objectprotected FlashMessageFactoryprotected FlashMessagesHolderThe currently set gzip options.The values of a specific response header.getHeaderFirst(String name) The first value of a specific header.The currently set response headers.protected JsonManagergetModel()TheJsonObjectwhich serves as the model for the response.protected ByteArrayOutputStreamgetOut()protected Rprotected Serverprotected SpincastConfigprotected SpincastUtilsintThe currentstatus codesent or to be send.byte[]Gets the current unsent bytes (AKA the buffer).Gets the current unsent characters (AKA the buffer), using theUTF-8encoding.getUnsentCharacters(String encoding) Gets the current unsent characters (AKA the buffer), using the specified encoding.protected XmlManagerprotected booleanShould Alert messages (and therefore Flash message) be added to the model when sending this one as Json or XML?booleanisClosed()Is the response closed? If so, nothing more can be sent...booleanAre the response headers sent? If this is the case, then the headers can't be changed anymore.protected booleanprotected booleanTry to determine is the response is characters based or not.protected booleanIfHTTP/2is used, you can push extra resources at the same time you response to a request.voidredirect()Sets a temporarily redirection header (302) to the current page.voidSets a temporarily redirection header (302).voidSets a redirection header.voidredirect(String newUrl, boolean permanently, FlashMessage flashMessage) Sets a redirection header, with a Flash message to display.voidredirect(String newUrl, boolean permanently, FlashMessageLevel flashMessageType, String flashMessageText) Sets a redirection header, with a Flash message to display.voidredirect(String newUrl, boolean permanently, FlashMessageLevel flashMessageType, String flashMessageText, JsonObject flashMessageVariables) Sets a redirection header, with a Flash message to display.voidSets the redirection headers with a specified3xxstatus code.voidredirect(String newUrl, int specific3xxCode, FlashMessage flashMessage) Sets the redirection headers with a specified3xxstatus code, and a Flash message to display.voidredirect(String newUrl, int specific3xxCode, FlashMessageLevel flashMessageType, String flashMessageText) Sets the redirection headers with a specified3xxstatus code, and a Flash message to display.voidredirect(String newUrl, int specific3xxCode, FlashMessageLevel flashMessageType, String flashMessageText, JsonObject flashMessageVariables) Sets the redirection headers with a specified3xxstatus code, and a Flash message to display.voidredirect(String newUrl, FlashMessage flashMessage) Sets a temporarily redirection header (302), with a Flash message to display.voidredirect(String newUrl, FlashMessageLevel flashMessageType, String flashMessageText) Sets a temporarily redirection header (302), with a Flash message to display.voidredirect(String newUrl, FlashMessageLevel flashMessageType, String flashMessageText, JsonObject flashMessageVariables) Sets a temporarily redirection header (302), with a Flash message to display.voidredirect(String newUrl, JsonObject flashMessageVariables) Sets a temporarily redirection header (302), with a Flash variables.voidredirect(FlashMessage flashMessage) Sets a temporarily redirection header (302) to the current page, with a Flash message to display.voidredirect(FlashMessageLevel flashMessageType, String flashMessageText) Sets a temporarily redirection header (302) to the current page, with a Flash message to display.voidredirect(FlashMessageLevel flashMessageType, String flashMessageText, JsonObject flashMessageVariables) Sets a temporarily redirection header (302) to the current page, with a Flash message to display.removeHeader(String name) Removes an header by its name.Clears the buffer (the unsent buffer, of course).Clears the buffer (the unsent buffer, of course!), resets the cookies, the headers, theContent-Typeand sets thestatus codeback to200.resetEverything(boolean resetCookies) Clears the buffer (the unsent buffer, of course), the headers, theContent-Typeand sets thestatus codeback to200.protected StringsaveFlashMessage(String url, FlashMessage flashMessage) Saves a Flash message.protected voidvoidsendBytes(byte[] bytes) Sends somebytes, without flushing.voidSends somebytesusing the specifiedContent-Type, without flushing.voidSend some bytes + flush if specified.voidsendCharacters(String content, String contentType) Sends a String, using the encoding returned bygetCharactersCharsetNameand using the specifiedContent-Type, without flushing.voidsendCharacters(String content, String contentType, boolean flush) Sends a String, using the encoding returned bygetCharactersCharsetNameand using the specifiedContent-Type.voidSends a String astext/html,UTF-8encoded, without flushing.voidSends a String astext/html,UTF-8encoded, and flushes, if specified.voidsendJson()Sends the model asapplication/json, without flushing.voidsendJson(boolean flush) Sends the model asapplication/json, and flushes, if specified.voidSerializes the object toJsonand sends asapplication/json, without flushing.voidSerializes the object toJson, sends asapplication/json, and flushes, if specified.voidSends aJsonString using theapplication/jsonContent-Type, without flushing.voidSends aJsonString using theapplication/jsonContent-Type, and flushes, if specified.voidParses the given String using theTemplatingEngine, then sends the result using the specifiedContent-Type, without flushing.voidParses the given String using theTemplatingEngine, then sends the result using the specifiedContent-Type, and flushes, if specified.voidsendParseHtml(String html) Parses the given String using theTemplatingEngineand the given parameters, then sends the result astext/html,UTF-8encoded.voidsendParseHtml(String html, boolean flush) Parses the given String using theTemplatingEngineand the given parameters, then sends the result astext/html,UTF-8encoded, and flushes, if specified.voidsendPlainText(String string) Sends a String astext/plain,UTF-8encoded, without flushing.voidsendPlainText(String string, boolean flush) Sends a String astext/plain,UTF-8encoded, and flushes, if specified.voidsendTemplate(String templatePath, boolean isClasspathPath, String contentType) Finds the specified template using theTemplatingEngine, evaluates it using the given parameters, then sends the result using the givencontentType, without flushing.voidsendTemplate(String templatePath, boolean isClasspathPath, String contentType, boolean flush) Finds the specified template using theTemplatingEngine, evaluates it using the given parameters, then sends the result using the givencontentType, and flushes, if specified.voidsendTemplate(String templatePath, String contentType) Finds the specified template using theTemplatingEngine, evaluates it using the given parameters, then sends the result using the givencontentType, without flushing.voidsendTemplate(String templatePath, String contentType, boolean flush) Finds the specified template using theTemplatingEngine, evaluates it using the given parameters, then sends the result using the givencontentType, and flushes, if specified.voidsendTemplateHtml(String templatePath) Finds theHTMLtemplate using theTemplatingEngine, evaluates it using the model that have been added to the response, then sends the result astext/html,UTF-8encoded, without flushing.voidsendTemplateHtml(String templatePath, boolean isClasspathPath) Finds theHTMLtemplate using theTemplatingEngine, evaluates it using the given parameters, then sends the result astext/html,UTF-8encoded.voidsendTemplateHtml(String templatePath, boolean isClasspathPath, boolean flush) Finds theHTMLtemplate using theTemplatingEngine, evaluates it using the given parameters, then sends the result astext/html,UTF-8encoded, and flushes, if specified.voidsendXml()Sends the model asapplication/xml, without flushing.voidsendXml(boolean flush) Sends the model asapplication/xml, and flushes, if specified.voidSerializes the object toXMLand sends asapplication/xml, without flushing.voidSerializes the object toXML, sends asapplication/xml, and flushes, if specified.voidSends someXMLusing theapplication/xmlContent-Type, without flushing.voidSends someXMLusing theapplication/xmlContent-Type, and flushes, if specified.setCacheSeconds(int cacheSeconds) Adds caching headers.setCacheSeconds(int cacheSeconds, boolean isPrivateCache) Adds caching headers for the specified number of seconds.setCharactersCharsetName(String charactersCharsetName) Sets the charset to use to convert characters to bytes.setContentType(String responseContentType) TheContent-Typeheader to use for the response.voidSets a cookie using the specified name, value and number of seconds to live.voidSets a cookie using the specified name, value, number of seconds to live and if it's http only.voidsetCookie(String name, String value, String path, String domain, Date expires, boolean secure, boolean httpOnly, CookieSameSite cookieSameSite, boolean discard, int version) Sets a cookie, using all available configurations.voidSets a cookie.voidsetCookie10years(String name, String value) Sets a permanent cookie (10 years) using the specified name and value.voidsetCookie10yearsSafe(String name, String value) Sets a permanent cookie (10 years) using the specified name and value.voidsetCookie1year(String name, String value) Sets a permanent cookie (1 years) using the specified name and value.voidsetCookie1yearSafe(String name, String value) Sets a permanent cookie (1 years) using the specified name and value.voidsetCookieSession(String name, String value) Sets a cookie using the specified name and value.voidsetCookieSessionSafe(String name, String value) Sets a cookie using the specified name and value.setGzipOption(GzipOption gzipOption) Enable or disable gzipping of the response.Set the value to a response header.Set multiple values to a response header.protected voidsetIsShouldGzip(boolean isShouldGzip) voidsetModel(JsonObject model) Replaces the current response model completely.protected voidsetRequestSizeValidated(boolean requestSizeValidated) setStatusCode(int responseStatusCode) Sets the response'sstatus codeto use.protected Stringprotected booleanvalidateCookie(Cookie cookie)
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
IS_RESPONSE_CHARACTERS_BASED_BY_DEFAULT
protected static final boolean IS_RESPONSE_CHARACTERS_BASED_BY_DEFAULT- See Also:
-
-
Constructor Details
-
SpincastResponseRequestContextAddon
@Inject public SpincastResponseRequestContextAddon(R requestContext, Server server, JsonManager jsonManager, XmlManager xmlManager, SpincastConfig spincastConfig, SpincastUtils spincastUtils, ETagFactory etagFactory, FlashMessagesHolder flashMessagesHolder, FlashMessageFactory flashMessageFactory, CookieFactory cookieFactory)
-
-
Method Details
-
getRequestContext
-
getServer
-
getExchange
-
getJsonManager
-
getXmlManager
-
getSpincastConfig
-
getSpincastUtils
-
getEtagFactory
-
getFlashMessagesHolder
-
getFlashMessageFactory
-
getCookieFactory
-
getBuffer
-
getOut
-
getModel
Description copied from interface:ResponseRequestContextAddonTheJsonObjectwhich serves as the model for the response. This object will be used by the templating engine or will be sent as is, often as anapplication/jsonresponse.This object is mutable.
- Specified by:
getModelin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getGzipBuffer
-
isRequestSizeValidated
protected boolean isRequestSizeValidated() -
setRequestSizeValidated
protected void setRequestSizeValidated(boolean requestSizeValidated) -
setGzipOption
Description copied from interface:ResponseRequestContextAddonEnable or disable gzipping of the response. The default isGzipOption.DEFAULTwhich will gzip the response only for someContent-Typesand only if agzip 'Accept-Encoding'header has been received from the client.- Specified by:
setGzipOptionin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getGzipOption
Description copied from interface:ResponseRequestContextAddonThe currently set gzip options.- Specified by:
getGzipOptionin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getStatusCode
public int getStatusCode()Description copied from interface:ResponseRequestContextAddonThe currentstatus codesent or to be send.- Specified by:
getStatusCodein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setStatusCode
Description copied from interface:ResponseRequestContextAddonSets the response'sstatus codeto use. Uses200by default. Note that thisstatus codecan be changed automatically if an exception is thrown.- Specified by:
setStatusCodein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getContentType
Description copied from interface:ResponseRequestContextAddonThe currentContent-Typesent or to be send.- Specified by:
getContentTypein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setContentType
Description copied from interface:ResponseRequestContextAddonTheContent-Typeheader to use for the response. MostsendXXX()methods will set this automatically.- Specified by:
setContentTypein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
isResponseCharactersBased
protected boolean isResponseCharactersBased()Try to determine is the response is characters based or not. This is allow us to use a default Content-Type header if none was specified. -
isClosed
public boolean isClosed()Description copied from interface:ResponseRequestContextAddonIs the response closed? If so, nothing more can be sent...- Specified by:
isClosedin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
redirect
public void redirect()Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302) to the current page.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
redirect
Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302) to the current page, with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
redirect
Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302) to the current page, with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
redirect
public void redirect(FlashMessageLevel flashMessageType, String flashMessageText, JsonObject flashMessageVariables) Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302) to the current page, with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
redirect
Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302).This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
redirect
Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302), with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>flashMessage- A Flash Message to pass to the target page.
-
redirect
Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302), with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>flashMessageType- The type of a Flash Message to pass to the target page.flashMessageText- The text of a Flash Message to pass to the target page.
-
redirect
public void redirect(String newUrl, FlashMessageLevel flashMessageType, String flashMessageText, JsonObject flashMessageVariables) Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302), with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>flashMessageType- The type of a Flash Message to pass to the target page.flashMessageText- The text of a Flash Message to pass to the target page.flashMessageVariables- The variables of a Flash Message to pass to the target page.
-
redirect
Description copied from interface:ResponseRequestContextAddonSets a temporarily redirection header (302), with a Flash variables.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>flashMessageVariables- The variables of a Flash Message to pass to the target page.
-
redirect
Description copied from interface:ResponseRequestContextAddonSets a redirection header.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>permanently- Iftrue, a301header will be sent. Iffalse,302will be sent.
-
redirect
Description copied from interface:ResponseRequestContextAddonSets a redirection header, with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>permanently- Iftrue, a301header will be sent. Iffalse,302will be sent.flashMessage- A Flash Message to pass to the target page.
-
redirect
public void redirect(String newUrl, boolean permanently, FlashMessageLevel flashMessageType, String flashMessageText) Description copied from interface:ResponseRequestContextAddonSets a redirection header, with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>permanently- Iftrue, a301header will be sent. Iffalse,302will be sent.flashMessageType- The type of a Flash Message to pass to the target page.flashMessageText- The text of a Flash Message to pass to the target page.
-
redirect
public void redirect(String newUrl, boolean permanently, FlashMessageLevel flashMessageType, String flashMessageText, JsonObject flashMessageVariables) Description copied from interface:ResponseRequestContextAddonSets a redirection header, with a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>permanently- Iftrue, a301header will be sent. Iffalse,302will be sent.flashMessageType- The type of a Flash Message to pass to the target page.flashMessageText- The text of a Flash Message to pass to the target page.flashMessageVariables- The variables of a Flash Message to pass to the target page.
-
redirect
Description copied from interface:ResponseRequestContextAddonSets the redirection headers with a specified3xxstatus code.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
redirect
public void redirect(String newUrl, int specific3xxCode, FlashMessageLevel flashMessageType, String flashMessageText) Description copied from interface:ResponseRequestContextAddonSets the redirection headers with a specified3xxstatus code, and a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>flashMessageType- The type of a Flash Message to pass to the target page.flashMessageText- The text of a Flash Message to pass to the target page.
-
redirect
public void redirect(String newUrl, int specific3xxCode, FlashMessageLevel flashMessageType, String flashMessageText, JsonObject flashMessageVariables) Description copied from interface:ResponseRequestContextAddonSets the redirection headers with a specified3xxstatus code, and a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>flashMessageType- The type of a Flash Message to pass to the target page.flashMessageText- The text of a Flash Message to pass to the target page.flashMessageVariables- The variables of a Flash Message to pass to the target page.
-
redirect
Description copied from interface:ResponseRequestContextAddonSets the redirection headers with a specified3xxstatus code, and a Flash message to display.This will NOT close the response and will NOT skip the remaining handlers! Throw a
RedirectExceptioninstead if you want to redirect the user immediately.- Specified by:
redirectin interfaceResponseRequestContextAddon<R extends RequestContext<?>>flashMessage- A Flash Message to pass to the target page.
-
saveFlashMessage
Saves a Flash message. Returned a modified version of the final URL to redirect to, if required. -
sendBytes
public void sendBytes(byte[] bytes) Description copied from interface:ResponseRequestContextAddonSends somebytes, without flushing.- Specified by:
sendBytesin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendBytes
Description copied from interface:ResponseRequestContextAddonSends somebytesusing the specifiedContent-Type, without flushing.- Specified by:
sendBytesin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendBytes
Send some bytes + flush if specified.- Specified by:
sendBytesin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
send
-
sendCharacters
Description copied from interface:ResponseRequestContextAddonSends a String, using the encoding returned bygetCharactersCharsetNameand using the specifiedContent-Type, without flushing.- Specified by:
sendCharactersin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendCharacters
Description copied from interface:ResponseRequestContextAddonSends a String, using the encoding returned bygetCharactersCharsetNameand using the specifiedContent-Type. Flushes the response, if specified. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
sendCharactersin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getCharactersCharsetName
Description copied from interface:ResponseRequestContextAddonThe charset to use to convert characters to bytes. Defaults to"UTF-8".- Specified by:
getCharactersCharsetNamein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCharactersCharsetName
Description copied from interface:ResponseRequestContextAddonSets the charset to use to convert characters to bytes. Defaults to"UTF-8". Make sure you use the same charset here than the one that is sent as the"Content-Type"header (which is also"UTF-8"by default, if you send data usingsendPlainText(),sendHtml()orsendJson()).- Specified by:
setCharactersCharsetNamein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendPlainText
Description copied from interface:ResponseRequestContextAddonSends a String astext/plain,UTF-8encoded, without flushing.- Specified by:
sendPlainTextin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendPlainText
Description copied from interface:ResponseRequestContextAddonSends a String astext/plain,UTF-8encoded, and flushes, if specified. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
sendPlainTextin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendHtml
Description copied from interface:ResponseRequestContextAddonSends a String astext/html,UTF-8encoded, without flushing.- Specified by:
sendHtmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendHtml
Description copied from interface:ResponseRequestContextAddonSends a String astext/html,UTF-8encoded, and flushes, if specified. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
sendHtmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendParseHtml
Description copied from interface:ResponseRequestContextAddonParses the given String using theTemplatingEngineand the given parameters, then sends the result astext/html,UTF-8encoded.- Specified by:
sendParseHtmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendParseHtml
Description copied from interface:ResponseRequestContextAddonParses the given String using theTemplatingEngineand the given parameters, then sends the result astext/html,UTF-8encoded, and flushes, if specified. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
sendParseHtmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendParse
Description copied from interface:ResponseRequestContextAddonParses the given String using theTemplatingEngine, then sends the result using the specifiedContent-Type, without flushing.- Specified by:
sendParsein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendParse
Description copied from interface:ResponseRequestContextAddonParses the given String using theTemplatingEngine, then sends the result using the specifiedContent-Type, and flushes, if specified. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
sendParsein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendTemplateHtml
Description copied from interface:ResponseRequestContextAddonFinds theHTMLtemplate using theTemplatingEngine, evaluates it using the model that have been added to the response, then sends the result astext/html,UTF-8encoded, without flushing.- Specified by:
sendTemplateHtmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>- Parameters:
templatePath- must be a classpath's relative path.
-
sendTemplateHtml
Description copied from interface:ResponseRequestContextAddonFinds theHTMLtemplate using theTemplatingEngine, evaluates it using the given parameters, then sends the result astext/html,UTF-8encoded.- Specified by:
sendTemplateHtmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>isClasspathPath- iftrue, the 'templatePath' is considered as a classpath's relative path. Iffalse, it is considered as an absolute file system path.
-
sendTemplateHtml
Description copied from interface:ResponseRequestContextAddonFinds theHTMLtemplate using theTemplatingEngine, evaluates it using the given parameters, then sends the result astext/html,UTF-8encoded, and flushes, if specified. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
sendTemplateHtmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>isClasspathPath- iftrue, the 'templatePath' is considered as a classpath's relative path. Iffalse, it is considered as an absolute file system path.
-
sendTemplate
Description copied from interface:ResponseRequestContextAddonFinds the specified template using theTemplatingEngine, evaluates it using the given parameters, then sends the result using the givencontentType, without flushing.- Specified by:
sendTemplatein interfaceResponseRequestContextAddon<R extends RequestContext<?>>- Parameters:
templatePath- must be a classpath's relative path.
-
sendTemplate
Description copied from interface:ResponseRequestContextAddonFinds the specified template using theTemplatingEngine, evaluates it using the given parameters, then sends the result using the givencontentType, and flushes, if specified. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
sendTemplatein interfaceResponseRequestContextAddon<R extends RequestContext<?>>- Parameters:
templatePath- must be a classpath's relative path.
-
sendTemplate
Description copied from interface:ResponseRequestContextAddonFinds the specified template using theTemplatingEngine, evaluates it using the given parameters, then sends the result using the givencontentType, without flushing.- Specified by:
sendTemplatein interfaceResponseRequestContextAddon<R extends RequestContext<?>>isClasspathPath- iftrue, the 'templatePath' is considered as a classpath's relative path. Iffalse, it is considered as an absolute file system path.
-
sendTemplate
public void sendTemplate(String templatePath, boolean isClasspathPath, String contentType, boolean flush) Description copied from interface:ResponseRequestContextAddonFinds the specified template using theTemplatingEngine, evaluates it using the given parameters, then sends the result using the givencontentType, and flushes, if specified. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
sendTemplatein interfaceResponseRequestContextAddon<R extends RequestContext<?>>isClasspathPath- iftrue, the 'templatePath' is considered as a classpath's relative path. Iffalse, it is considered as an absolute file system path.
-
sendJson
public void sendJson()Description copied from interface:ResponseRequestContextAddonSends the model asapplication/json, without flushing.- Specified by:
sendJsonin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendJson
public void sendJson(boolean flush) Description copied from interface:ResponseRequestContextAddonSends the model asapplication/json, and flushes, if specified.Note that once the response is flushed, no header can be added or changed anymore.
- Specified by:
sendJsonin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendJson
Description copied from interface:ResponseRequestContextAddonSends aJsonString using theapplication/jsonContent-Type, without flushing.Synonym of :
sendCharacters(jsonString, "application/json")- Specified by:
sendJsonin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendJson
Description copied from interface:ResponseRequestContextAddonSends aJsonString using theapplication/jsonContent-Type, and flushes, if specified.Note that once the response is flushed, no header can be added or changed anymore.
Synonym of :
sendCharacters(jsonString, "application/json", flush)- Specified by:
sendJsonin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendJson
Description copied from interface:ResponseRequestContextAddonSerializes the object toJsonand sends asapplication/json, without flushing.If the specified Object is a
String, it will be considered as already beingJSONand will be send as is.- Specified by:
sendJsonin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendJson
Description copied from interface:ResponseRequestContextAddonSerializes the object toJson, sends asapplication/json, and flushes, if specified.Note that once the response is flushed, no header can be added or changed anymore.
If the specified Object is a
String, it will be considered as already beingJSONand will be send as is.- Specified by:
sendJsonin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendXml
public void sendXml()Description copied from interface:ResponseRequestContextAddonSends the model asapplication/xml, without flushing.- Specified by:
sendXmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendXml
public void sendXml(boolean flush) Description copied from interface:ResponseRequestContextAddonSends the model asapplication/xml, and flushes, if specified.Note that once the response is flushed, no header can be added or changed anymore.
- Specified by:
sendXmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendXml
Description copied from interface:ResponseRequestContextAddonSends someXMLusing theapplication/xmlContent-Type, without flushing.Synonym of :
sendCharacters(xml, "application/xml")- Specified by:
sendXmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendXml
Description copied from interface:ResponseRequestContextAddonSends someXMLusing theapplication/xmlContent-Type, and flushes, if specified.Note that once the response is flushed, no header can be added or changed anymore.
Synonym of :
sendCharacters(xml, "application/xml", flush)- Specified by:
sendXmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendXml
Description copied from interface:ResponseRequestContextAddonSerializes the object toXMLand sends asapplication/xml, without flushing.If the specified Object is a
String, it will be considered as already beingXMLand will be send as is.- Specified by:
sendXmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
sendXml
Description copied from interface:ResponseRequestContextAddonSerializes the object toXML, sends asapplication/xml, and flushes, if specified.Note that once the response is flushed, no header can be added or changed anymore.
If the specified Object is a
String, it will be considered as already beingXMLand will be send as is.- Specified by:
sendXmlin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
addAlertsToModel
protected void addAlertsToModel() -
isAddAlertsToModel
protected boolean isAddAlertsToModel()Should Alert messages (and therefore Flash message) be added to the model when sending this one as Json or XML? -
resetBuffer
Description copied from interface:ResponseRequestContextAddonClears the buffer (the unsent buffer, of course).- Specified by:
resetBufferin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
resetEverything
Description copied from interface:ResponseRequestContextAddonClears the buffer (the unsent buffer, of course!), resets the cookies, the headers, theContent-Typeand sets thestatus codeback to200.- Specified by:
resetEverythingin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
resetEverything
Description copied from interface:ResponseRequestContextAddonClears the buffer (the unsent buffer, of course), the headers, theContent-Typeand sets thestatus codeback to200.- Specified by:
resetEverythingin interfaceResponseRequestContextAddon<R extends RequestContext<?>>- Parameters:
resetCookies- iftrue, cookies that have been added on the current response will be reset too.
-
getUnsentBytes
public byte[] getUnsentBytes()Description copied from interface:ResponseRequestContextAddonGets the current unsent bytes (AKA the buffer).- Specified by:
getUnsentBytesin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getUnsentCharacters
Description copied from interface:ResponseRequestContextAddonGets the current unsent characters (AKA the buffer), using theUTF-8encoding.- Specified by:
getUnsentCharactersin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getUnsentCharacters
Description copied from interface:ResponseRequestContextAddonGets the current unsent characters (AKA the buffer), using the specified encoding.- Specified by:
getUnsentCharactersin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
removeHeader
Description copied from interface:ResponseRequestContextAddonRemoves an header by its name.- Specified by:
removeHeaderin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setHeader
Description copied from interface:ResponseRequestContextAddonSet the value to a response header. If the header already exists, its current values are overwritten. If the value isnull, the header will be removed (same behavior asremoveHeader(String name))- Specified by:
setHeaderin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setHeader
Description copied from interface:ResponseRequestContextAddonSet multiple values to a response header. If the header already exists, its current values are overwritten. If the lists isnullor empty, the header will be removed (same behavior asremoveHeader(String name))- Specified by:
setHeaderin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
addHeaderValue
Description copied from interface:ResponseRequestContextAddonAdds a value to a response header. If the header already has values, the new one is added. If the value isnull, it won't be added.- Specified by:
addHeaderValuein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
addHeaderValues
Description copied from interface:ResponseRequestContextAddonAdds a list of values to a response header. If the header already has values, the new ones are added. If the values arenull, nothing will be added.- Specified by:
addHeaderValuesin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getHeaders
Description copied from interface:ResponseRequestContextAddonThe currently set response headers. The map is mutable! Also the returned implementation is aTreeMapwith case insensitive keys.- Specified by:
getHeadersin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getHeader
Description copied from interface:ResponseRequestContextAddonThe values of a specific response header. The list is mutable! The name is case insensitive. Returns an empty list if the header was not found.- Specified by:
getHeaderin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getHeaderFirst
Description copied from interface:ResponseRequestContextAddonThe first value of a specific header. The name is case insensitive. Returnsnullif the header is not found.- Specified by:
getHeaderFirstin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
isHeadersSent
public boolean isHeadersSent()Description copied from interface:ResponseRequestContextAddonAre the response headers sent? If this is the case, then the headers can't be changed anymore.- Specified by:
isHeadersSentin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setIsShouldGzip
protected void setIsShouldGzip(boolean isShouldGzip) -
isShouldGzip
protected boolean isShouldGzip() -
end
public void end()Description copied from interface:ResponseRequestContextAddonFlushes everything and closes the response. Nothing more can be sent after this (but the remainingroute handlerswill still be called).- Specified by:
endin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
flush
public void flush()Description copied from interface:ResponseRequestContextAddonFlushes the current response. If not already specified, a defaultstatus codeandContent-Typewill be added. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
flushin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
flush
public void flush(boolean close) Description copied from interface:ResponseRequestContextAddonFlushes the current response. If not already specified on the response, a defaultstatus codeandcontent-typewill be added. Note that once the response is flushed, no header can be added or changed anymore.- Specified by:
flushin interfaceResponseRequestContextAddon<R extends RequestContext<?>>- Parameters:
close- Iftrue, the response will be closed and no more data can be sent. This has the same effect than callingResponseRequestContextAddon.end().
-
setCacheSeconds
Description copied from interface:ResponseRequestContextAddonAdds caching headers.- Specified by:
setCacheSecondsin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCacheSeconds
Description copied from interface:ResponseRequestContextAddonAdds caching headers for the specified number of seconds. Adds caching headers.- Specified by:
setCacheSecondsin interfaceResponseRequestContextAddon<R extends RequestContext<?>>isPrivateCache- iftrue, the cache will be flagged as "private".
-
setModel
Description copied from interface:ResponseRequestContextAddonReplaces the current response model completely.Use
ResponseRequestContextAddon.getModel()instead to get the current model instance and add properties to it.- Specified by:
setModelin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
addAlert
Description copied from interface:ResponseRequestContextAddonAdds an Alert that is, in general, displayed at the top of the page to show the user an Error, a Warning or a confirmation message.Those alerts are available using the "spincast.alerts" templating variable. If any, a
Flash Messagesis also added to this variable.- Specified by:
addAlertin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
createAlert
-
getCookiesAdded
Description copied from interface:ResponseRequestContextAddonGets the cookies already added to the response as a Map, using their names as the keys.NOTE : use the
RequestRequestContextAddon.getCookiesValues()from therequest()add-on instead to get the cookies sent by the user!- Specified by:
getCookiesAddedin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getCookieAdded
Description copied from interface:ResponseRequestContextAddonGets a cookie already added to the response, by its name.NOTE : use the
RequestRequestContextAddon.getCookieValue(String)from therequest()add-on instead to get a cookie sent by the user!- Specified by:
getCookieAddedin interfaceResponseRequestContextAddon<R extends RequestContext<?>>- Returns:
- the cookie or
nullif not found.
-
setCookie
Description copied from interface:ResponseRequestContextAddonSets a cookie.- Specified by:
setCookiein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCookieSession
Description copied from interface:ResponseRequestContextAddonSets a cookie using the specified name and value.By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomainand the cookie is valid for the time of the session only.- Specified by:
setCookieSessionin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCookieSessionSafe
Description copied from interface:ResponseRequestContextAddonSets a cookie using the specified name and value. The cookie will be "secure", "httpOnly" and aCookieSameSitevalue ofCookieSameSite.LAX.By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomainand the cookie is valid for the time of the session only.- Specified by:
setCookieSessionSafein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCookie1year
Description copied from interface:ResponseRequestContextAddonSets a permanent cookie (1 years) using the specified name and value.By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomain.- Specified by:
setCookie1yearin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCookie1yearSafe
Description copied from interface:ResponseRequestContextAddonSets a permanent cookie (1 years) using the specified name and value. The cookie will be "secure", "httpOnly" and aCookieSameSitevalue ofCookieSameSite.LAX.By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomain.- Specified by:
setCookie1yearSafein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCookie10years
Description copied from interface:ResponseRequestContextAddonSets a permanent cookie (10 years) using the specified name and value.By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomain.- Specified by:
setCookie10yearsin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCookie10yearsSafe
Description copied from interface:ResponseRequestContextAddonSets a permanent cookie (10 years) using the specified name and value. The cookie will be "secure", "httpOnly" and aCookieSameSitevalue ofCookieSameSite.LAX.By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomain.- Specified by:
setCookie10yearsSafein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCookie
Description copied from interface:ResponseRequestContextAddonSets a cookie using the specified name, value and number of seconds to live.By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomain.- Specified by:
setCookiein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
setCookie
Description copied from interface:ResponseRequestContextAddonSets a cookie using the specified name, value, number of seconds to live and if it's http only.By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomain.- Specified by:
setCookiein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
addCookieSafe
-
setCookie
public void setCookie(String name, String value, String path, String domain, Date expires, boolean secure, boolean httpOnly, CookieSameSite cookieSameSite, boolean discard, int version) Description copied from interface:ResponseRequestContextAddonSets a cookie, using all available configurations.- Specified by:
setCookiein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
validateCookie
-
deleteCookie
Description copied from interface:ResponseRequestContextAddonDeletes a cookie. In fact, this sets the cookie'sexpires datein the past so the user's browser will remove it.isExpired()will returntrueafter you called this method.- Specified by:
deleteCookiein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
deleteAllCookiesUserHas
public void deleteAllCookiesUserHas()Description copied from interface:ResponseRequestContextAddonDeletes all cookies! Not only the new cookies that have been added to the response, but also the cookies that have been received in the request!In fact, this method sets the
expires dateof the cookies in the past so the user's browser will remove them.- Specified by:
deleteAllCookiesUserHasin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
createCookie
Description copied from interface:ResponseRequestContextAddonCreates a cookie using the given name (nullvalue).By default, the public host (
SpincastConfig.getPublicServerHost()) is uses as the cookie'sdomainand the cookie is valid for the time of the session only.You have to add the cookie using the
ResponseRequestContextAddon.setCookie(Cookie)method after it is properly created.- Specified by:
createCookiein interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
addForm
Description copied from interface:ResponseRequestContextAddonAdds aFormobject to the response's model and links its validation messages to the default "validation" root element.In other words, adding a form will result in those elements to the response's model :
- [formName] => the form itself
- [validation] => validation messages for the form with keys such as "[formName].something" and "[formName].somethingElse".
- Specified by:
addFormin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
addForm
Description copied from interface:ResponseRequestContextAddonAdds aFormobject to the response's model and links its validation messages to the specified validation element.In other words, adding a form will result in those elements to the response's model :
- [formName] => the form itself
- [validationElementName] => validation messages for the form with keys such as "[formName].something" and "[formName].somethingElse".
- Specified by:
addFormin interfaceResponseRequestContextAddon<R extends RequestContext<?>>
-
getResourcesToPush
-
push
public ResponseRequestContextAddon<R> push(HttpMethod httpMethod, String path, Map<String, List<String>> requestHeaders) Description copied from interface:ResponseRequestContextAddonIfHTTP/2is used, you can push extra resources at the same time you response to a request.If the embedded server deals with a HTTTP/2 request, it will push the extra resources by itself. If it deals with an HTTP/1.X request (for example if it is behind a reverse-proxy) it will send
Linkheaders to the potential proxy in front of it and it is the proxy that will be in charge of doing the actual push.Beware that pushing resources does not always result in an increase of performance and may lead to wasted bandwidth (the client may decide to not use those pushed resources).
- Specified by:
pushin interfaceResponseRequestContextAddon<R extends RequestContext<?>>path- The absolute path to the resource to push, starting with "/" (or it will be added). No scheme, host, port but may contain a querystring.requestHeaders- The headers for requesting the resource. May benull. Those headers will only be used if the embedded server pushes the resources by itself. If it is behind a reverse-proxy and ask this proxy to push the resources, those headers won't be used but a "as=" attribute may be added to help the proxy serve the proper content-type.
-
tweakResourceToPushPath
-