From: <asa...@us...> - 2012-12-01 07:50:54
|
Revision: 7813 http://sourceforge.net/p/htmlunit/code/7813 Author: asashour Date: 2012-12-01 07:50:50 +0000 (Sat, 01 Dec 2012) Log Message: ----------- WebClient.closeAllWindows() to delete all temporary created big files. Issue 1344 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-01 06:27:27 UTC (rev 7812) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-01 07:50:50 UTC (rev 7813) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="asashour" issue="1344"> + WebClient.closeAllWindows() to delete all temporary created big files. + </action> <action type="fix" dev="asashour"> JavaScript: .outerHTML of "basefont", "col", "embed" and "wbr" have forbidden end tag (FF). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2012-12-01 06:27:27 UTC (rev 7812) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2012-12-01 07:50:50 UTC (rev 7813) @@ -133,6 +133,7 @@ private String virtualHost_; private final CookieSpecFactory htmlUnitCookieSpecFactory_; private final WebClientOptions usedOptions_ = new WebClientOptions(); + private List<File> temporaryFiles_; /** * Creates a new HTTP web connection instance. @@ -655,7 +656,7 @@ return new DownloadedContent.InMemory(new byte[] {}); } - return downloadContent(httpEntity.getContent()); + return downloadContent(this, httpEntity.getContent()); } /** @@ -665,6 +666,11 @@ * @throws IOException in case of read issues */ public static DownloadedContent downloadContent(final InputStream is) throws IOException { + return downloadContent(null, is); + } + + private static DownloadedContent downloadContent(final HttpWebConnection connection, final InputStream is) + throws IOException { if (is == null) { return new DownloadedContent.InMemory(new byte[] {}); } @@ -683,6 +689,12 @@ bos.writeTo(fos); // what we have already read IOUtils.copyLarge(is, fos); // what remains from the server response fos.close(); + if (connection != null) { + if (connection.temporaryFiles_ == null) { + connection.temporaryFiles_ = new ArrayList<File>(); + } + connection.temporaryFiles_.add(file); + } return new DownloadedContent.OnFile(file, true); } } @@ -726,6 +738,11 @@ httpClient_.getConnectionManager().shutdown(); httpClient_ = null; } + if (temporaryFiles_ != null) { + for (final File file : temporaryFiles_) { + file.delete(); + } + } } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-12-01 06:27:27 UTC (rev 7812) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-12-01 07:50:50 UTC (rev 7813) @@ -5391,7 +5391,7 @@ // */ // @Test // @Alerts(FF3_6 = "ajax: jQuery ajax - failing cross-domain (0, 2, 2)", -// FF10 = "ajax: jQuery ajax - atom+xml (0, 1, 1)", CHROME = "ajax: jQuery ajax - failing cross-domain (0, 2, 2)", +//FF10 = "ajax: jQuery ajax - atom+xml (0, 1, 1)", CHROME = "ajax: jQuery ajax - failing cross-domain (0, 2, 2)", // IE = "ajax: jQuery.ajax - If-Modified-Since support (no cache) (0, 3, 3)") // @NotYetImplemented(FF) // public void test_480() throws Exception { |