0
我写了一个ServerResource下面与restlet-android-2.1.4。如果我将SIZE设置为1024 * 12 + 485,它就可以工作。但是,如果我将SIZE更改为1024 * 12 + 486,则此句柄将处于待处理状态。奇怪的失败GET服务器资源与1024 * 12 + 486长度响应
public class DataResource extends ServerResource {
public static final int SIZE = 1024 * 12 + 485;
@Get
public Representation getResource(Representation entity) {
return new OutputRepresentation(MediaType.ALL) {
@Override
public void write(OutputStream outputStream) throws IOException {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < SIZE; i++) {
sb.append('E');
}
outputStream.write(sb.toString().getBytes());
outputStream.close();
}
};
}
}
您正在使用哪个Restlet HTTP服务器?您是否将Jetty或Simple扩展添加到类路径中? –
我正在使用默认的Restlet组件来启动服务器。在线程https://gist.github.com/fxp/016f9e39e8f30a3b4edd中运行此代码,无需码头或其他扩展 – fxp
请尝试添加org.restlet.ext.simple.jar和依赖关系,并查看它是否工作得更好。 –