Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebResponseData


         
          resource.sendHeaders(resourceContext);
          resource.send(resourceContext);
         
          return new WebResponseImpl(
              new WebResponseData(
                  new ByteArrayInputStream(baos.toByteArray()),
                  HttpServletResponse.SC_OK,
                  "OK",
                  resourceContext.getHeaders()),
                  settings.getURL(),
View Full Code Here


         
          resource.sendHeaders(resourceContext);
          resource.send(resourceContext);
         
          return new WebResponseImpl(
              new WebResponseData(
                  new ByteArrayInputStream(baos.toByteArray()),
                  HttpServletResponse.SC_OK,
                  "OK",
                  resourceContext.getHeaders()),
                  settings.getURL(),
View Full Code Here


    public WebResponse getResponse(WebRequest webRequest) throws IOException {
        ClientRequest jerseyClientRequest = adaptHtmlunitRequest(webRequest);
        ClientResponse jerseyClientResponse = processJerseyClientRequest(jerseyClientRequest);
        WebResponseData htmlunitResponseData = adaptJerseyClientResponse(jerseyClientResponse);
        return new WebResponse(htmlunitResponseData, webRequest, 0);
    }
View Full Code Here

            }
        }

        String content = jerseyClientResponse.getEntity(String.class);
        if (content == null) content = "";
        return new WebResponseData(content.getBytes("UTF-8"), jerseyClientResponse.getStatus(), jerseyClientResponse.getClientResponseStatus().getReasonPhrase(), headers);
    }
View Full Code Here

            }
        };

        try {
            final String decompileScript = (String) factory.call(action);
            final WebResponseData wrd = new WebResponseData(decompileScript.getBytes(), response.getStatusCode(),
                response.getStatusMessage(), response.getResponseHeaders());
            return new WebResponseImpl(wrd, response.getRequestSettings().getUrl(),
                response.getRequestSettings().getHttpMethod(), response.getLoadTime());
        }
        catch (final Exception e) {
View Full Code Here

     * @return true if the load succeeded; false if the load failed
     */
    public boolean jsxFunction_loadXML(final String strXML) {
        try {
            final List<NameValuePair> emptyList = Collections.emptyList();
            final WebResponseData data = new WebResponseData(strXML.getBytes(), HttpStatus.SC_OK, null, emptyList);
            final WebResponse webResponse = new WebResponseImpl(data, (URL) null, (HttpMethod) null, 0);
            final XmlPage page = new XmlPage(webResponse, getWindow().getWebWindow());
            setDomNode(page);
            return true;
        }
View Full Code Here

     * @return a web response with the new content
     * @throws IOException if an encoding problem occurred
     */
    protected WebResponse replaceContent(final WebResponse wr, final String newContent) throws IOException {
        final byte[] body = newContent.getBytes(wr.getContentCharset());
        final WebResponseData wrd = new WebResponseData(body, wr.getStatusCode(), wr.getStatusMessage(),
            wr.getResponseHeaders());
        return new WebResponseImpl(wrd, wr.getRequestSettings().getUrl(), wr.getRequestSettings().getHttpMethod(),
                wr.getLoadTime());
    }
View Full Code Here

            final String contentType, final int responseCode, final String responseMessage) throws IOException {
        final List<NameValuePair> headers = new ArrayList<NameValuePair>();
        final String encoding = "UTF-8";
        headers.add(new NameValuePair("content-type", contentType + "; charset=" + encoding));
        final byte[] body = content.getBytes(encoding);
        final WebResponseData wrd = new WebResponseData(body, responseCode, responseMessage, headers);
        return new WebResponseImpl(wrd, wr.getUrl(), wr.getHttpMethod(), 0);
    }
View Full Code Here

        Collection<String> headerNames = inProcResponse.getHeaderNames();
        for (String headerName : headerNames) {
            String headerValue = inProcResponse.getHeader(headerName);
            headers.add(new NameValuePair(headerName, headerValue));
        }
        return new WebResponseData(inProcResponse.getContentBytes(), inProcResponse.getStatus(), inProcResponse.getReason(), headers);
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.WebResponseData

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.