We're using RESTlet to do a small little REST server for a project we have. We set up a bunch of routes in a class inheriting from 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;
}
The problem: If I request a .js file in the JAR via Ajax from a web page (also loaded via CLAP from this JAR), it'll only return the first 7737 bytes of that file and then hang. I can't get it to return the rest of the file. It always hangs after exactly the same number of bytes. 1 in 50 times it works.
Any ideas why it's hanging? Can I just turn off chunked encoding for CLAP and static files (all ours are quite small).
This is driving us nuts.