|
|
|
@ -3,6 +3,7 @@ package org.gcube.datatransfer.resolver.http;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.net.SocketException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLConnection;
|
|
|
|
|
import java.net.URLStreamHandler;
|
|
|
|
@ -106,7 +107,6 @@ public class HttpResolver extends HttpServlet {
|
|
|
|
|
response.setContentType("unknown/unknown");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
URL url = new URL(null, uri, new URLStreamHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -125,21 +125,45 @@ public class HttpResolver extends HttpServlet {
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e){
|
|
|
|
|
response.sendError(404);
|
|
|
|
|
logger.error("Exception:", e);
|
|
|
|
|
logger.error("URLConnection Exception:", e);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
IOUtils.copy(in, out);
|
|
|
|
|
|
|
|
|
|
out.flush();
|
|
|
|
|
out.close();
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//CHANGED BY FRANCESCO M.
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
IOUtils.copy(in, out);
|
|
|
|
|
|
|
|
|
|
} catch (SocketException e){
|
|
|
|
|
if (!e.getClass().getSimpleName().equals("ClientAbortException"))
|
|
|
|
|
throw e;
|
|
|
|
|
else
|
|
|
|
|
logger.warn("Skipping ClientAbortException: "+e.getMessage());
|
|
|
|
|
} finally {
|
|
|
|
|
IOUtils.closeQuietly(in);
|
|
|
|
|
IOUtils.closeQuietly(out);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
logger.error("Exception:", e);
|
|
|
|
|
response.sendError(404);
|
|
|
|
|
// response.sendError(404);
|
|
|
|
|
|
|
|
|
|
//CHANGED BY FRANCESCO M.
|
|
|
|
|
if(!response.isCommitted())
|
|
|
|
|
response.sendError(404);
|
|
|
|
|
else
|
|
|
|
|
logger.warn("Response already committed, skipped send Error 404");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|