Properties:
Name | Type | Description |
---|---|---|
sessionId |
string | [readonly] The ID that identifies this session. The ID is assigned by the HTTP server. |
user |
string | [readonly] The user ID associated with this session. |
timeout |
number | (default: |
urlMapper |
function | (default: |
Example
HTTPSession {
onRequest: req =>
{
if (req.method === "GET")
{
req.response(200, "OK")
.body("You requested " + req.url.href)
.send();
}
else
{
req.response(404, "Not Found")
.send();
}
}
}
Extends
Methods
-
Closes this session. This removes this particular session instance from the parent HTTP server.
-
response (code, status)server.HTTPResponse Deprecated : Use the `response` method of server.HTTPServer.HTTPRequestEvent instead.
-
Creates and returns a response object.
Name Type Description code
number The HTTP status code.
status
string The HTTP status text.
Returns:
Type Description server.HTTPResponse The response object.
Events
-
Is triggered when a request comes in.
Name Type Description request
server.HTTPServer.HTTPRequestEvent The request event.
-
Is triggered when a response is ready to be sent. This allows to make modifications to the response before sending.
Example
WebSession { filesystem: localFs root: "/var/www" indexFile: "index.html" onResponseReady: r => { r.enableCrossOriginIsolation(); } }
Name Type Description response
server.HTTPResponse The response object.