Hi Jochen, This looks like a bug. Could you enter an issue and attach a minimal Eclipse project to reproduce the issue?
As a workaround, have you try pluging in another HTTP connector (via org.restlet.ext.simple.jar for example)? Thanks, Jerome -- http://restlet.com http://twitter.com/#!/jlouvel 2013/1/28 Jochen Mader <[email protected]> > Forgot to mention the vewrsion: > I tried it in 2.1.1 and 2.2 SNAPSHOT > > I am currently trying to stream files from my restlet application. > The following works: > File theFileToDownload = new File("test.mp3"); > FileRepresentation rep = new FileRepresentation(theFileToDownload, > MediaType.APPLICATION_OCTET_STREAM); > Disposition disp = new Disposition(Disposition.TYPE_ATTACHMENT); > disp.setFilename(theFileToDownload.getName()); > disp.setSize(theFileToDownload.length()); > rep.setDisposition(disp); > return rep; > > Now I tried switching to JAX RS using: > File file = new File("test.mp3"); > > Response.ResponseBuilder response = Response.ok((Object) file); > response.header("Content-Disposition", > "attachment; filename=new-android-book.mp3"); > return response.build(); > > Accessing the ressource causes Restlet to throw the following exception > and stop the download: > java.io.IOException: Timeout while writing to the queue-based output stream > at org.restlet.engine.io.PipeStream$2.write(PipeStream.java:108) > at java.io.OutputStream.write(OutputStream.java:99) > at java.io.OutputStream.write(OutputStream.java:58) > at > org.restlet.ext.jaxrs.internal.provider.ByteArrayProvider.writeTo(ByteArrayProvider.java:96) > at > org.restlet.ext.jaxrs.internal.provider.ByteArrayProvider.writeTo(ByteArrayProvider.java:55) > at > org.restlet.ext.jaxrs.internal.wrappers.provider.SingletonProvider.writeTo(SingletonProvider.java:350) > at > org.restlet.ext.jaxrs.internal.util.JaxRsOutputRepresentation.write(JaxRsOutputRepresentation.java:112) > at org.restlet.engine.io.BioUtils$1.run(BioUtils.java:331) > at org.restlet.service.TaskService$1$1.run(TaskService.java:135) > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) > at > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) > at java.util.concurrent.FutureTask.run(FutureTask.java:138) > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) > at java.lang.Thread.run(Thread.java:680) > > > This happens with all variations of trying to get files streamed through > JAX RS like: > > File file = new File("test.mp3"); > ByteArrayOutputStream byteArrayOutputStream = new > ByteArrayOutputStream(); > FileInputStream fileInputStream = new FileInputStream(file); > > byte[] buffer = new byte[16384]; > > for (int len = fileInputStream.read(buffer); len > 0; len = > fileInputStream > .read(buffer)) { > byteArrayOutputStream.write(buffer, 0, len); > } > > fileInputStream.close(); > return Response.ok(byteArrayOutputStream.toByteArray()).build(); > > Any suggestions on what I might do wrong? > > ------------------------------------------------------ > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3046388 > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3047900

