I've written a proxy of sorts in Java (and Jetty). Anyway, it works great, but sometimes
...
final OutputStream realOs = res.getOutputStream();
...
InputStream is = url.openStream();
int i;
while ((i = is.rea开发者_JS百科d(buffer)) != -1) {
realOs.write(buffer, 0, i);
}
fails with IOException. I've noticed that it mostly happens with large binary files, i.e. flash and Safari browser...
I'm puzzled...
This can happen if the browser is closed (or the user cancels the download) while you're still writing to the socket. The browser closes the socket, so your OutputStream
no longer has anything to write to.
Unfortunately it's hard to tell for sure whether this is really the case - in which case it's not an issue - or whether there's something more insidious going on.
精彩评论