Module ringo/jsgi/connector

Low-level JSGI adapter implementation.


AsyncResponse (request, timeout)

Creates a streaming asynchronous response. The returned response object can be used both synchronously from the current thread or asynchronously from another thread, even after the original thread has finished execution. AsyncResponse objects are threadsafe.

To enable async support inside a Servlet 3.0+ container, an additional <async-supported>true</async-supported> element in the web.xml deployment descriptor might be required. This indicates that Ringo's JsgiServlet supports asynchronous request processing.


const response = new AsyncResponse(request, 10000);
response.start(200, {"Content-Type": "text/plain"});

// this functions returns a ringo promise
doSomeAsyncStuff().then(function(data) {
  // write out result
}, function() {
  // just close the connection in case of an error

return response;


Object request

the JSGI request object

Number timeout

time in milliseconds in which the async operation has to be completed; otherwise the request is aborted by the Servlet container. A negative value lets the async operation never time out. Defaults to 30 seconds.

handleRequest (moduleId, functionObj, request)

Handle a JSGI request.


String moduleId

the module id. Ignored if functionObj is already a function.

Function|String functionObj

the function, either as function object or function name to be imported from the module moduleId.

Object request

the JSGI request object



the JSGI response object