我们正在使用RESTlet为我们的项目做一个小的REST服务器.我们在继承自的类中设置了一堆路由Application:
public static void createRestServer(ApplicationContext appCtx, String propertiesPath) throws Exception {
// Create a component
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8081);
component.getClients().add(Protocol.FILE);
component.getClients().add(Protocol.CLAP);
Context context = component.getContext().createChildContext();
RestServer application = new RestServer(context);
application.getContext().getParameters().add("useForwardedForHeader", "true");
application.getContext().getAttributes().put("appCtx", appCtx);
application.getContext().getAttributes().put("file", propertiesPath);
// Attach the application to the component and start it
component.getDefaultHost().attach(application);
component.start();
}
private RestServer(Context context) {
super(context);
}
public synchronized Restlet createInboundRoot() {
Router router = new Router(getContext());
// we then have a bunch of these
router.attach("/accounts/{accountId}", AccountFetcher.class); //LIST Account level
// blah blah blah
// finally some stuff for static files:
//
Directory directory = new Directory(getContext(),
LocalReference.createClapReference(LocalReference.CLAP_CLASS, "/"));
directory.setIndexName("index.html");
router.attach("/", directory);
return router;
}
问题:如果我通过Ajax从网页请求JAR中的.js文件(也通过此JAR中的CLAP加载),它将只返回该文件的前7737个字节然后挂起.我无法让它返回文件的其余部分.它总是在完全相同的字节数后挂起.它有效50次.
任何想法为什么它挂?我可以关闭CLAP和静态文件的分块编码(我们所有的都非常小).
这让我们疯了.