Class IndexHtmlResponse
- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionIndexHtmlResponse(VaadinRequest vaadinRequest, VaadinResponse vaadinResponse, org.jsoup.nodes.Document document) Create a response object for client side bootstrapping.IndexHtmlResponse(VaadinRequest vaadinRequest, VaadinResponse vaadinResponse, org.jsoup.nodes.Document document, UI ui) Create a response object for client side bootstrapping with UI. -
Method Summary
Modifier and TypeMethodDescription@Nullable ContentSecurityPolicyGets the Content Security Policy that is sent with this response.@Nullable StringGets the nonce of this response, which Vaadin puts on every<script>element of the document and allows in thescript-srcdirective of the Content Security Policy.org.jsoup.nodes.DocumentGet the index.html response in form of aDocumentinstance.getUI()Gets the UI that will be displayed on the generated HTML page.Get the request which triggers the Index HTML response.Get the Vaadin response object including all the headers which will be sent to browser.
-
Constructor Details
-
IndexHtmlResponse
public IndexHtmlResponse(VaadinRequest vaadinRequest, VaadinResponse vaadinResponse, org.jsoup.nodes.Document document, UI ui) Create a response object for client side bootstrapping with UI.- Parameters:
vaadinRequest- the vaadin request which is handlingvaadinResponse- the corresponding vaadin responsedocument- theDocumentobject of the response pageui- the UI for the bootstrap
-
IndexHtmlResponse
public IndexHtmlResponse(VaadinRequest vaadinRequest, VaadinResponse vaadinResponse, org.jsoup.nodes.Document document) Create a response object for client side bootstrapping.- Parameters:
vaadinRequest- the vaadin request which is handlingvaadinResponse- the corresponding vaadin responsedocument- theDocumentobject of the response page
-
-
Method Details
-
getVaadinRequest
Get the request which triggers the Index HTML response.- Returns:
- the Vaadin request
-
getVaadinResponse
Get the Vaadin response object including all the headers which will be sent to browser.- Returns:
- the Vaadin response
-
getDocument
public org.jsoup.nodes.Document getDocument()Get the index.html response in form of aDocumentinstance.- Returns:
- the index document
-
getUI
Gets the UI that will be displayed on the generated HTML page.- Returns:
- the UI
-
getCspNonce
Gets the nonce of this response, which Vaadin puts on every<script>element of the document and allows in thescript-srcdirective of the Content Security Policy.A new nonce is created for every response when the application runs with the
CspMode.STRICTmode. Scripts added by anIndexHtmlRequestListenerget the nonce automatically, but the value can also be used for other content that needs it. The nonce is not put on the scripts in development mode.- Returns:
- the nonce, or
nullif the mode is notCspMode.STRICT - Since:
- 25.4
-
getContentSecurityPolicy
Gets the Content Security Policy that is sent with this response.The policy is created when the application runs with the
CspMode.STRICTmode. AnIndexHtmlRequestListenercan add or override directives for resources of the application, such asconnect-src,img-src,frame-srcorreport-to.Do not change
script-src: it holds the nonce and'strict-dynamic', so replacing it withContentSecurityPolicy.setDirective(String, String...)blocks every script of the page, and host sources added to it are ignored by the browser. To load a script from another origin, add a<script>element to the document, which gets the nonce, or load it from a script that is already trusted.The header is written after all listeners have run. It is not written in development mode, because the development server and the development tools need
eval. In production mode, the request fails with anIllegalStateExceptionif the response already has aContent-Security-Policyheader when the page is written, for example from a servlet filter that runs before Vaadin. A filter that writes its header only when the response is committed, such as Spring Security'sHeaderWriterFilterby default, cannot be detected; its policy should be configured here instead.- Returns:
- the mutable policy, or
nullif the mode is notCspMode.STRICT - Since:
- 25.4
-