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和依賴關係,並查看它是否工作得更好。 –