Hi,
I'm using 2.1.2 with the Jetty HTTP connector. I'd appreciate any pointers on
the following issue.
I tried serving a video file to a browser that loads with an <embed src='...'>
tag by creating a ServerResource implementing the handle() method and returning
a FileRepresentation of my video:
public Representation handle()
{
return new FileRepresentation(new File(...), MediaType.VIDEO_MP4);
}
that didn't work. It turned out I had to set the representation as the response
entity:
public Representation handle()
{
Representation r = new FileRepresentation(new File(...),
MediaType.VIDEO_MP4);
response.setEntity(r);
return r;
}
But the gives my the following exception:
The connection was broken. It was probably closed by the client.
org.eclipse.jetty.io.EofException
at
org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:952)
at
org.eclipse.jetty.http.AbstractGenerator.blockForOutput(AbstractGenerator.java:518)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:182)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:101)
at org.restlet.engine.io.BioUtils.copy(BioUtils.java:82)
at
org.restlet.representation.FileRepresentation.write(FileRepresentation.java:271)
at
org.restlet.engine.adapter.ServerCall.writeResponseBody(ServerCall.java:510)
at
org.restlet.engine.adapter.ServerCall.sendResponse(ServerCall.java:454)
at
org.restlet.ext.jetty.internal.JettyCall.sendResponse(JettyCall.java:312)
caused by:
Caused by: java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:122)
at sun.nio.ch.IOUtil.write(IOUtil.java:93)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:352)
at
org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:305)
at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:356)
at
org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:891)
... 22 more
I trying googling for examples and I couldn't find any documentation about how
to create ServerResources and what the rules are for implementation the
Representation interface. It's pretty much trial and error and shooting in the
dark, so any hint will probably help.
Regards,
Boris
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3058146