}
if(seqId>=0){
client.addSequenceId(seqId);
}
}
NativeObject env = new PersistableObject() {
public Object get(String key, Scriptable start) {
Object storedValue = super.get(key, start);
if(storedValue != ScriptableObject.NOT_FOUND)
return storedValue;
if ("REQUEST_METHOD".equals(key)) {
return request.getMethod();
}
if ("SERVLET_REQUEST".equals(key)) {
return request;
}
if ("SERVLET_RESPONSE".equals(key)) {
return response;
}
if ("PERSEVERE_REQUEST_HELPER".equals(key)) {
return rh;
}
if ("SERVLET_FILTER_CHAIN".equals(key)) {
return filterChain;
}
if ("SCRIPT_NAME".equals(key)) {
return request.getServletPath();
}
if ("PATH_INFO".equals(key)) {
String path = request.getRequestURI();
return path.substring(request.getContextPath().length());
}
if ("CONTENT_TYPE".equals(key)) {
return request.getContentType();
}
if ("CONTENT_LENGTH".equals(key)) {
return request.getContentLength();
}
if ("QUERY_STRING".equals(key)) {
return request.getQueryString();
}
if ("SERVER_NAME".equals(key)) {
return request.getServerName();
}
if ("SERVER_PORT".equals(key)) {
return request.getServerPort();
}
if ("SERVER_PROTOCOL".equals(key)) {
return request.getProtocol();
}
if ("jsgi.version".equals(key)) {
List array = Persevere.newArray();
array.add(0);
array.add(1);
return array;
}
if ("jsgi.url_scheme".equals(key)) {
return request.getScheme();
}
if ("jsgi.input".equals(key)) {
try {
return request.getInputStream();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
if ("jsgi.error".equals(key)) {
return System.err;
}
if ("jsgi.multithread".equals(key)) {
return true;
}
if ("jsgi.multiprocess".equals(key)) {
return false;
}
if ("jsgi.run_once".equals(key)) {
return false;
}
return Undefined.instance;
}
public Object getCoreValue(String name){
return get(name, this);
}
@Override
public Object[] getIds() {
List list = new ArrayList();
list.addAll(Arrays.asList(super.getIds()));
list.addAll(Arrays.asList(new String[]{"REQUEST_METHOD","SCRIPT_NAME","PATH_INFO","CONTENT_TYPE","CONTENT_LENGTH","QUERY_STRING","SERVER_NAME","SERVER_PORT","SERVER_PROTOCOL","jsgi.version","jsgi.url_scheme","jsgi.input","jsgi.error","jsgi.multithread","jsgi.multiprocess","jsgi.run_once"}));
return list.toArray();
}
};
try {
ScriptRuntime.setObjectProtoAndParent(env, global);
} catch (Exception e1) {
}
Enumeration headerNames = request.getHeaderNames();
while(headerNames.hasMoreElements()){
String headerName = (String) headerNames.nextElement();
if(!(headerName.equals("Content-Type") || headerName.equals("Content-Length")))
env.put("HTTP_" + headerName.toUpperCase(), env, request.getHeader(headerName));
}
Object result = ((Function) global.get("coreApp", global)).call(PersevereContextFactory.getContext(), global, global,
new Object[] { env });
if (result instanceof Scriptable) {
Object status = ((Scriptable) result).get("status", (Scriptable) result);