com.vaadin.flow.internal.
Class ResponseWriter
All Implemented Interfaces:
The class that handles writing the response data into the response.
For internal use only. May be renamed or removed in a future release.
Since:
1.0.
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionResponseWriter
(DeploymentConfiguration deploymentConfiguration) Create a response writer with the given deployment configuration.
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
acceptsBrotliResource
(jakarta.servlet.http.HttpServletRequest request) Returns whether it is ok to serve a Brotli version of the given resource.
protected boolean
acceptsGzippedResource
(jakarta.servlet.http.HttpServletRequest request) Returns whether it is ok to serve a gzipped version of the given resource.
void
writeResponseContents
(String filenameWithPath, URL resourceUrl, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Writes the contents and content type (if available) of the given resourceUrl to the response.
-
Constructor Details
-
ResponseWriter
Create a response writer with the given deployment configuration.
Parameters:
deploymentConfiguration
- the deployment configuration to use, notnull
-
-
Method Details
-
writeResponseContents
public void writeResponseContents(String filenameWithPath, URL resourceUrl, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Writes the contents and content type (if available) of the given resourceUrl to the response.
WARNING: note that this should not be used for a
resourceUrl
that represents a directory! For security reasons, the directory contents should not be ever written into theresponse
, and the implementation which is used for setting the content length relies onURLConnection.getContentLengthLong()
method which returns incorrect values for directories.Parameters:
filenameWithPath
- the name of the file being sentresourceUrl
- the URL to the file, reported by the servlet containerrequest
- the request object to read fromresponse
- the response object to write toThrows:
IOException
- if the servlet container threw an exception while locating the resource -
acceptsGzippedResource
protected boolean acceptsGzippedResource(jakarta.servlet.http.HttpServletRequest request) Returns whether it is ok to serve a gzipped version of the given resource.
If this method returns true, the browser is ok with receiving a gzipped version of the resource. In other cases, an uncompressed file must be sent.
Parameters:
request
- the request for the resourceReturns:
true if the servlet should attempt to serve a gzipped version of the resource, false otherwise
-
acceptsBrotliResource
protected boolean acceptsBrotliResource(jakarta.servlet.http.HttpServletRequest request) Returns whether it is ok to serve a Brotli version of the given resource.
If this method returns true, the browser is ok with receiving a Brotli version of the resource. In other cases, an uncompressed or gzipped file must be sent.
Parameters:
request
- the request for the resourceReturns:
true if the servlet should attempt to serve a Brotli version of the resource, false otherwise
-