Map<String, String> files) {
IConstructor methodVal = makeMethod(method);
IMap headersVal = makeMap(headers);
IMap paramsVal= makeMap(parms);
IMap filesVal= makeMap(files);
ISourceLocation loc = vf.sourceLocation(URIUtil.assumeCorrect("request", "", uri));
try {
synchronized (callee.getEval()) {
callee.getEval().__setInterrupt(false);
Result<IValue> response = callee.call(argTypes, new IValue[] { loc, methodVal, headersVal, paramsVal, filesVal }, null);
return translateResponse(method, response.getValue());
}
}
catch (Throw rascalException) {
ctx.getStdErr().println(rascalException.getMessage());
return new Response(Status.INTERNAL_ERROR, "text/plain", rascalException.getMessage());
}
catch (Throwable unexpected) {
ctx.getStdErr().println(unexpected.getMessage());
unexpected.printStackTrace(ctx.getStdErr());
return new Response(Status.INTERNAL_ERROR, "text/plain", unexpected.getMessage());
}
}
private Response translateResponse(Method method, IValue value) {
IConstructor cons = (IConstructor) value;
initMethodAndStatusValues(ctx);
if (cons.getName().equals("fileResponse")) {
return translateFileResponse(method, cons);
}
else {
return translateTextResponse(method, cons);
}
}
private Response translateFileResponse(Method method, IConstructor cons) {
ISourceLocation l = (ISourceLocation) cons.get("file");
IString mimeType = (IString) cons.get("mimeType");
IMap header = (IMap) cons.get("header");
URI uri = l.getURI();
Response response;
try {
response = new Response(Status.OK, mimeType.getValue(), ctx.getResolverRegistry().getInputStream(uri));
addHeaders(response, header);