1 38 package com.gargoylesoftware.htmlunit; 39 40 import java.io.IOException ; 41 import java.net.URL ; 42 43 55 public class ImmediateRefreshHandler implements RefreshHandler { 56 57 64 public void handleRefresh(final Page page, final URL url, final int seconds) throws IOException { 65 final WebWindow window = page.getEnclosingWindow(); 66 if( window == null ) { 67 return; 68 } 69 final WebClient client = window.getWebClient(); 70 if( page.getWebResponse().getUrl().toExternalForm().equals( url.toExternalForm() ) ) { 71 final String msg = "Refresh Aborted by HtmlUnit: " + 72 "Attempted to refresh a page using an ImmediateRefreshHandler " + 73 "which could have caused an OutOfMemoryError " + 74 "Please use WaitingRefreshHandler or ThreadedRefreshHandler instead."; 75 throw new RuntimeException (msg); 76 } 77 client.getPage( window, new WebRequestSettings( url ) ); 78 } 79 80 } 81 | Popular Tags |