我用restlet-android-2.1.4在下面写了一个ServerResource。如果我将 SIZE 设置为 1024 * 12 + 485,它可以工作。但是,如果我将 SIZE 更改为 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();
}
};
}
}