Module for HTTP request processing using modified JSGI interface conventions.

To be instantiated per-request.

A stand-alone main-like CGI app require()s and constructs an instance of this (supplying request parameters such as pathTranslated via RequestParams, and then delegates, from eg. its top-level control flow, to the process() member function.

Implements the SGML web server functionaliy explained in the SGML Web reference.

Processes (markuprequest.process()) the requested URL (as of the request parameters, scriptName, pathInfo and pathTranslated) by either

  • processing (the file in) scriptName if it has the '.sgm` extension, or
  • serving (the file in) pathTranslated as-is if it has pathTranslated has an extension, or
  • processing (the file in) pathTranslated (potentially appending file suffixes/extensions), and either using it as main SGML file (with .sgm appended), or, process a master file in the parent directory having the same name as the directory (with .sgm appended), if present the value of pathTranslated, if any, is then used/supplied for PATH_TRANSLATED/PATH_TRANSLATED_CONTENT access.

Implements ErrorHandler.

Constructor

new Markuprequest(requestParams, requestBody, response)

Parameters

Name Type Description
requestParams RequestParams
requestBody Readable
response Markupresponse

Name Description
running_as_errorhandler Flag set by caller (middleware) if markuprequest should populate the STATUS system-specific entity from the initial value of req.
running_as_middleware Flag set by caller (middleware) if markuprequest should throw an exception (if true) or invoke `socket.

Name Description
abort_request Called on errors during rendering an error page, when an SGML error occured during rendering a request page's content (eg.
process Main entry point for request processing.
process_error_response Called to render an HTTP error response/page where this.
process_script_name Performs request processing on `requestParams.
reset Resets/dealloc constructed processing components.
startContent Called by chain/tokenizer when prolog parsing has completed.

Member Details

abort_request()

Called on errors during rendering an error page, when an SGML error occured during rendering a request page's content (eg. as opposed to prolog processing in which case a proper HTTP status and error page rendering cycle is (attempted to be) produced first.

process()

Main entry point for request processing.

Takes URL/parameters to service from request parameters map.

process_error_response()

Called to render an HTTP error response/page where this.response.status is expected to have been set to a non-200 status previously.

process_script_name()

Performs request processing on requestParams.scriptName as template and requestParams.pathTranslated as client document.

Called from process_sgml() after re-determining scriptName/pathTranslated from initial value of scriptName. Can also be called directly from outside (ie. when host web container provides SGML files via scriptName).

reset()

Resets/dealloc constructed processing components.

Cf. platformbaseentitymanager.reset().

running_as_errorhandler

Flag set by caller (middleware) if markuprequest should populate the STATUS system-specific entity from the initial value of req.statusCode.

running_as_middleware

Flag set by caller (middleware) if markuprequest should throw an exception (if true) or invoke socket.destroy() (if false) when handling errors (such as during rendering error pages).

startContent()

Called by chain/tokenizer when prolog parsing has completed.

Evaluates parameters parsed from HTTP/HTTP2 simple link process declaration and sets response headers accordingly.

Returns

non-falsey (relevant only for async) return indicates to the caller to return immediately in turn (roll-up call stack); falsey/undefined return indicates caller can continue b/c no async I/O has been kicked from here