Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebRequestSettings


         * Performs the download and calls the callback method.
         */
        public void run() {
            final WebClient client = getWindow().getWebWindow().getWebClient();
            final Scriptable scope = callback_.getParentScope();
            final WebRequestSettings settings = new WebRequestSettings(url_);
            try {
                final WebResponse webResponse = client.loadWebResponse(settings);
                final String content = webResponse.getContentAsString();
                LOG.debug("Downloaded content: " + StringUtils.abbreviate(content, 512));
                final Object[] args = new Object[] {content};
View Full Code Here


            final String js = StringUtils.substringAfter(action, "javascript:");
            webClient.getJavaScriptEngine().execute(page, js, "Form action", 0);
        }
        else {
            // download should be done ASAP, response will be loaded into a window later
            final WebRequestSettings requestSettings = getHtmlForm().getWebRequestSettings(null);
            final String target = page.getResolvedTarget(jsxGet_target());
            webClient.download(page.getEnclosingWindow(), target, requestSettings, "JS form.submit()");
        }
    }
View Full Code Here

        out.close();
        return new RequestFileAttachment(temp, false, (AbstractHttpRequest<?>) request);
    }

    private byte[] downloadResource(HtmlPage page, HtmlElement htmlElement, URL url) throws IOException {
        WebRequestSettings wrs = null;

        wrs = new WebRequestSettings(url);
        wrs.setAdditionalHeader("Referer", page.getWebResponse().getRequestSettings().getUrl().toString());
        client.addRequestHeader("Accept", acceptTypes.get(htmlElement.getTagName().toLowerCase()));
        return client.getPage(wrs).getWebResponse().getContentAsBytes();

    }
View Full Code Here

     * Sends HTTP GET request and loads response object.
     */
    protected void loadResponse(String pageURL)
        throws Exception
    {
        WebRequestSettings webRequestSettings = new WebRequestSettings(new URL(baseURL, pageURL), SubmitMethod.GET);
        this.response = webClient.loadWebResponse(webRequestSettings);
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.WebRequestSettings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.