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
Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:
this < that => <0
this == that => 0
this > that => >0
This method may also be accessed via the <
<=
<=>
>=
and >
shortcut operators. If not overridden the default
implementation compares the toStr
representations. Also see docLang.
Examples:
3.compare(8) => -1
8.compare(3) => 1
8.compare(8) => 0
3 <=> 8 => -1 // shortcut for 3.compare(8)
Compare this object to the specified for equality. This
method may be accessed via the == and != shortcut operators.
If not overridden the default implementation compares for
reference equality using the === operator. If this method
is overridden, then hash() must also be overridden such that
any two objects which return true for equals() must return
the same value for hash(). This method must accept null
and
return false.
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.
The file being serviced by this FileWeblet.
Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.
Get the modified time of the file floored to 1 second which is the most precise that HTTP can deal with.
Convenience method to respond to a DELETE request. Default implementation returns a 501 Not implemented error.
Handle GET request for the file.
Convenience method to respond to a HEAD request. Default implementation returns a 501 Not implemented error.
Convenience method to respond to a OPTIONS request. Default implementation returns a 501 Not implemented error.
Convenience method to respond to a POST request. Default implementation returns a 501 Not implemented error.
Convenience method to respond to a PUT request. Default implementation returns a 501 Not implemented error.
Convenience method to respond to a TRACE request. Default implementation returns a 501 Not implemented error.
The WebReq instance for this current web request. Raise an exception if the current actor thread is not serving a web request.
The WebRes instance for this current web request. Raise an exception if the current actor thread is not serving a web request.
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Return a string representation of this object.
Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:
a->x a.trap("x", null)
a->x() a.trap("x", null)
a->x = b a.trap("x", [b])
a->x(b) a.trap("x", [b])
a->x(b, c) a.trap("x", [b, c])
The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Static
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
make
FileWeblet is used to service an HTTP request on a sys::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.