From: David M. G. <mic...@gm...> - 2014-01-02 12:47:34
|
Hi all, For the following url: http://archivoespañoldearte.revistas.csic.es/index.php/aea/article/download/552/549<http://xn--archivoespaoldearte-53b.revistas.csic.es/index.php/aea/article/download/552/549> When dispatched in ie8 a pdf file is automatically downloaded. As i understand htmlunit should emulate the browser behavior. When running the following code: package test; import java.io.IOException; import java.net.MalformedURLException; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.WebClient; public class ForceDownload { public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException { WebClient client = new WebClient(); final String downloadUrl = " http://archivoespañoldearte.revistas.csic.es/index.php/aea/article/download/552/549<http://xn--archivoespaoldearte-53b.revistas.csic.es/index.php/aea/article/download/552/549> "; final Page page = client.getPage(downloadUrl); System.out.println(page.getWebResponse().getContentType()); } } I get as output: application/force-download Is there a way to say to htmlunit to download the pdf automatically like in ie8? Thanks, David |