模块 ringo/jsgi/connector
低级 JSGI 适配器实现。
Functions
- AsyncResponse (request, timeout)
 - handleRequest (moduleId, functionObj, request)
 
AsyncResponse (request, timeout)
创建流异步响应。返回的响应对象既可以在当前线程中同步使用,也可以从另一个线程异步使用,即使原始线程执行完毕后也是如此。 AsyncResponse 对象是线程安全的。
要在 Servlet 3.0+ 容器内启用异步支持,可能需要 web.xml 部署描述符中的其他 <async-supported>true</async-supported> 元素。这表明 Ringo 的 JsgiServlet 支持异步请求处理。
Example
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
  response.write(data);
  response.close();
}, function() {
  // just close the connection in case of an error
  response.close();
});
return response;
        Parameters
| 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)
处理JSGI请求
Parameters
| 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  | 
                
Returns
| Object | the JSGI response object  |