We are trying to relay a FileRepresentation, and downloading directly from the
Restlet server works fine. I can do a manual cURL/wget and retrieve the whole
file correctly.
However, when relaying the input stream through a Servlet it seems like the
client socket is being reset.
Representation rep =
myClient.get(MediaType.APPLICATION_OCTET_STREAM);
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachement;
filename=\"" + fileName + "\"");
outStream = response.getOutputStream();
inStream = rep.getStream();
byte[] buffer = new byte[65535000];
int read = inStream.read(buffer, 0, 65535);
while (read != -1)
{
outStream.write(buffer, 0, read);
outStream.flush();
read = inStream.read(buffer, 0, 65535);
}
outStream.flush();
response.flushBuffer();
What we end up seeing on the server:
Caused by: java.nio.channels.ClosedChannelException
at
sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:135)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:326)
at org.simpleframework.transport.Appender.write(Appender.java:343)
at org.simpleframework.transport.Appender.write(Appender.java:322)
at org.simpleframework.transport.Appender.write(Appender.java:297)
And I'm not sure what's going wrong with our client where the socket connection
to the Restlet server is being prematurely closed before the entire file has
been transmitted.
Does anyone have any hints or suggestions?
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3090366