@Override public WebResponse getResponse(WebRequest request) throws IOException { request.setAdditionalHeader(HttpHeaders.ACCEPT_ENCODING, "identity"); return super.getResponse(request); } };
@Override public WebResponse getResponse(WebRequest request) throws IOException { if (urlFragmentToMonitor == null || request.getUrl().toString().contains(urlFragmentToMonitor)) { rawRequestBody = request.getRequestBody(); WebResponse response = super.getResponse(request); rawResponse = response.getContentAsString(); return response; } return super.getResponse(request); }
public WebResponse getResponse(WebRequest request) throws IOException { WebResponse response = super.getResponse(request); String u = request.getUrl().toExternalForm(); if (u.contains(".js")) { System.err.println(u); String content = response.getContentAsString("UTF-8"); if (content.contains("append: function")) { System.err.println(content); } //change content WebResponseData data = new WebResponseData(content.getBytes("UTF-8"), response.getStatusCode(), response.getStatusMessage(), response.getResponseHeaders()); response = new WebResponse(data, request, response.getLoadTime()); } return response; } };
/** * Delivers the content for an alternate URL as if it comes from the requested URL. * @param webRequest the original web request * @param url the URL from which the content should be retrieved * @return the response * @throws IOException if a problem occurred */ protected WebResponse deliverFromAlternateUrl(final WebRequest webRequest, final URL url) throws IOException { final URL originalUrl = webRequest.getUrl(); webRequest.setUrl(url); final WebResponse resp = super.getResponse(webRequest); resp.getWebRequest().setUrl(originalUrl); return resp; }
/** * Delivers the content for an alternate URL as if it comes from the requested URL. * @param webRequestSettings the original web request settings * @param url the URL from which the content should be retrieved * @return the response * @throws IOException if a problem occurred */ protected WebResponse deliverFromAlternateUrl(final WebRequestSettings webRequestSettings, final URL url) throws IOException { final URL originalUrl = webRequestSettings.getUrl(); webRequestSettings.setUrl(url); final WebResponse resp = super.getResponse(webRequestSettings); resp.getRequestSettings().setUrl(originalUrl); return resp; }
/** * Delivers the content for an alternate URL as if it comes from the requested URL. * @param webRequestSettings the original web request settings * @param url the URL from which the content should be retrieved * @return the response * @throws IOException if a problem occurred */ protected WebResponse deliverFromAlternateUrl(final WebRequestSettings webRequestSettings, final URL url) throws IOException { final URL originalUrl = webRequestSettings.getUrl(); webRequestSettings.setUrl(url); final WebResponse resp = super.getResponse(webRequestSettings); resp.getRequestSettings().setUrl(originalUrl); return resp; }
/** * Delivers the content for an alternate URL as if it comes from the requested URL. * @param webRequestSettings the original web request settings * @param url the URL from which the content should be retrieved * @return the response * @throws IOException if a problem occurred */ protected WebResponse deliverFromAlternateUrl(final WebRequestSettings webRequestSettings, final URL url) throws IOException { final URL originalUrl = webRequestSettings.getUrl(); webRequestSettings.setUrl(url); final WebResponse resp = super.getResponse(webRequestSettings); resp.getRequestSettings().setUrl(originalUrl); return resp; }
/** * Delivers the content for an alternate URL as if it comes from the requested URL. * @param webRequest the original web request * @param url the URL from which the content should be retrieved * @return the response * @throws IOException if a problem occurred */ protected WebResponse deliverFromAlternateUrl(final WebRequest webRequest, final URL url) throws IOException { final URL originalUrl = webRequest.getUrl(); webRequest.setUrl(url); final WebResponse resp = super.getResponse(webRequest); resp.getWebRequest().setUrl(originalUrl); return resp; }
@Override public WebResponse getResponse(final WebRequest request) throws IOException { String protocol = request.getUrl().getProtocol(); // Default web response is retrieved using commons HttpClient. // It assumes HttpClient created internally by HtmlUnit is using the // default registry. We check for supported schemes by the default // registry. boolean canHandle = SchemeRegistryFactory.createDefault() .get(protocol) != null; if (!canHandle) { // For unsupported schemes, it tries to read the response using // native URL connection. String data = ResourceUtils.readAsText(request.getUrl()); return new StringWebResponse(data, request.getUrl()); } return super.getResponse(request); } };
public WebResponse getResponse( WebRequest request ) throws IOException { Cookie jsCookie = webClient.getCookieManager().getCookie("JSESSIONID"); if (jsCookie != null && (!jsCookie.getValue().startsWith("\"") && !jsCookie.getValue().endsWith("\""))) { Cookie newCookie = new Cookie(jsCookie.getDomain(), jsCookie.getName(), "\"" + jsCookie.getValue() + "\"", jsCookie.getPath(), jsCookie.getExpires(), jsCookie.isSecure()); webClient.getCookieManager().removeCookie(jsCookie); webClient.getCookieManager().addCookie(newCookie); } return super.getResponse(request); } };