sys::Obj web::FileWeblet : web::Weblet
FileWeblet is used to service an HTTP request on a
File. It handles all the dirty details for cache control, compression, modification time, ETags, etc.
Default implementation uses gzip encoding if gzip is supported by the client and the file's MIME type has a "text" media type.
Current implementation supports ETags and Modification time for cache validation. It does not specify any cache control directives.
protected virtual Bool checkNotModified()
Check if the request passed headers indicating it has cached version of the file. If the file has not been modified, then service the request as 304 and return true. This method supports ETag "If-None-Match" and "If-Modified-Since" modification time.
Checks if the file being served is under the given directory. If it is not, a 404 response is immediately sent, short-circuiting any further attempts to serve the file.
virtual Str etag()
Compute the ETag for the file being serviced which uniquely identifies the file version. The default implementation is a hash of the modified time and the file size. The result of this method must conform to the ETag syntax and be wrapped in quotes.
Extra response headers to add for all 3xx and 2xx responses
const File file
The file being serviced by this FileWeblet.
new make(File file)
Constructor with file to service.
virtual DateTime modified()
Get the modified time of the file floored to 1 second which is the most precise that HTTP can deal with.
virtual override Void onGet()
Handle GET request for the file.
virtual override Void onService()