restlet和ajax,java - Restlet, CLAP, Ajax, and chunk timeouts - Stack Overflow

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值