class web::FileWeblet

sys::Obj
  web::FileWeblet : web::Weblet

Source

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.

checkNotModified

protected virtual Bool checkNotModified()

Source

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.

checkUnderDir

This checkUnderDir(File dir)

Source

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.

FileWeblet(file).checkUnderDir(dir).onService
etag

virtual Str etag()

Source

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.

extraResHeaders

[Str:Str]? extraResHeaders

Source

Extra response headers to add for all 3xx and 2xx responses

file

const File file

Source

The file being serviced by this FileWeblet.

make

new make(File file)

Source

Constructor with file to service.

modified

virtual DateTime modified()

Source

Get the modified time of the file floored to 1 second which is the most precise that HTTP can deal with.

onGet

virtual override Void onGet()

Source

Handle GET request for the file.

onService

virtual override Void onService()

Source