diff --git a/source/de/anomic/http/JakartaCommonsHttpResponse.java b/source/de/anomic/http/JakartaCommonsHttpResponse.java index 575e18daf..89542ccbd 100644 --- a/source/de/anomic/http/JakartaCommonsHttpResponse.java +++ b/source/de/anomic/http/JakartaCommonsHttpResponse.java @@ -123,6 +123,15 @@ public class JakartaCommonsHttpResponse { return new httpdByteCountInputStream(inStream, incomingAccountingName); } + /** + * Abort Download, e. g. when proxy connection was closed + * Do not forget to call closeStream afterwards... + * + */ + public void abort() { + method.abort(); + } + /* * (non-Javadoc) * diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java index 4ac36e8e8..4b168ac34 100644 --- a/source/de/anomic/http/httpdProxyHandler.java +++ b/source/de/anomic/http/httpdProxyHandler.java @@ -61,6 +61,7 @@ import java.net.InetAddress; import java.net.MalformedURLException; import java.net.NoRouteToHostException; import java.net.Socket; +import java.net.SocketException; import java.net.SocketTimeoutException; import java.net.UnknownHostException; import java.nio.charset.Charset; @@ -665,6 +666,9 @@ public final class httpdProxyHandler { chunkedOut.flush(); } } // end hasBody + } catch(SocketException se) { + // client cut proxy connection, abort download + res.abort(); } finally { // if opened ... if(res != null) { @@ -1090,6 +1094,9 @@ public final class httpdProxyHandler { chunked.finish(); } outStream.flush(); + } catch(SocketException se) { + // connection closed by client, abort download + res.abort(); } finally { // if opened ... if(res != null) { @@ -1383,6 +1390,9 @@ public final class httpdProxyHandler { forceConnectionClose(conProp); return; } + } catch (SocketException se) { + // connection closed by client, abort download + response.abort(); } catch (final Exception e) { throw new IOException(e.getMessage()); } finally {