/** * Creates a faked WebResponse for the request with the provided content. * @param wr the web request for which a response should be created * @param content the content to place in the response * @param contentType the content type of the response * @return a web response with the provided content * @throws IOException if an encoding problem occurred */ protected WebResponse createWebResponse(final WebRequest wr, final String content, final String contentType) throws IOException { return createWebResponse(wr, content, contentType, 200, "OK"); }
@Override public WebResponse getResponse(WebRequest request) throws IOException { WebResponse response = super.getResponse(request); if (response.getWebRequest().getUrl().toString().contains("www.google-analytics.com")) { return this.createWebResponse(response.getWebRequest(), "", "application/javascript", 200, "Ok"); } if (response.getWebRequest().getUrl().toString().endsWith(".css")) { return this.createWebResponse(response.getWebRequest(), "", "text/css", 200, "Ok"); } return super.getResponse(request); } }
/** * Creates a faked WebResponse for the request with the provided content. * @param wr the web request for which a response should be created * @param content the content to place in the response * @param contentType the content type of the response * @return a web response with the provided content * @throws IOException if an encoding problem occurred */ protected WebResponse createWebResponse(final WebRequest wr, final String content, final String contentType) throws IOException { return createWebResponse(wr, content, contentType, 200, "OK"); }
/** * Creates a faked WebResponse for the request with the provided content. * @param wr the web request for which a response should be created * @param content the content to place in the response * @param contentType the content type of the response * @return a web response with the provided content * @throws IOException if an encoding problem occurred */ protected WebResponse createWebResponse(final WebRequestSettings wr, final String content, final String contentType) throws IOException { return createWebResponse(wr, content, contentType, 200, "OK"); }
/** * Creates a faked WebResponse for the request with the provided content. * @param wr the web request for which a response should be created * @param content the content to place in the response * @param contentType the content type of the response * @return a web response with the provided content * @throws IOException if an encoding problem occurred */ protected WebResponse createWebResponse(final WebRequestSettings wr, final String content, final String contentType) throws IOException { return createWebResponse(wr, content, contentType, 200, "OK"); }
/** * Creates a faked WebResponse for the request with the provided content. * @param wr the web request for which a response should be created * @param content the content to place in the response * @param contentType the content type of the response * @return a web response with the provided content * @throws IOException if an encoding problem occurred */ protected WebResponse createWebResponse(final WebRequestSettings wr, final String content, final String contentType) throws IOException { return createWebResponse(wr, content, contentType, 200, "OK"); }