@Test public void buildContentCharset() throws Exception { this.response.addHeader("Content-Type", "text/html; charset=UTF-8"); WebResponse webResponse = this.responseBuilder.build(); assertThat(webResponse.getContentCharset(), equalTo(StandardCharsets.UTF_8)); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentCharset() on the wrapped webResponse object. */ @Override public Charset getContentCharset() { return wrappedWebResponse_.getContentCharset(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentCharset() on the wrapped connection object. */ public String getContentCharset() { return wrappedWebResponse_.getContentCharset(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentCharset() on the wrapped connection object. */ public String getContentCharset() { return wrappedWebResponse_.getContentCharset(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentCharset() on the wrapped webResponse object. */ @Override public Charset getContentCharset() { return wrappedWebResponse_.getContentCharset(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentCharset() on the wrapped connection object. */ public String getContentCharset() { return wrappedWebResponse_.getContentCharset(); }
@Override public String getContentCharset() { return delegate.getContentCharset(); }
/** * Returns the response content as a string, using the charset/encoding specified in the server response. * @return the response content as a string, using the charset/encoding specified in the server response * or null if the content retrieval was failing */ public String getContentAsString() { return getContentAsString(getContentCharset()); }
/** * {@inheritDoc} */ @Override public Charset getCharset() { if (originalCharset_ == null) { originalCharset_ = getWebResponse().getContentCharset(); } return originalCharset_; }
/** * {@inheritDoc} */ @Override public Charset getCharset() { if (originalCharset_ == null) { originalCharset_ = getWebResponse().getContentCharset(); } return originalCharset_; }
/** * Returns the response content as a string, using the charset/encoding specified in the server response. * @return the response content as a string, using the charset/encoding specified in the server response * or null if the content retrieval was failing */ public String getContentAsString() { return getContentAsString(getContentCharset()); }
/** * Parses and then inserts the specified HTML content into the HTML content currently being parsed. * @param html the HTML content to push */ public void pushInputString(final String html) { page_.registerParsingStart(); page_.registerInlineSnippetParsingStart(); try { final WebResponse webResponse = page_.getWebResponse(); final Charset charset = webResponse.getContentCharset(); final String url = webResponse.getWebRequest().getUrl().toString(); final XMLInputSource in = new XMLInputSource(null, url, null, new StringReader(html), charset.name()); ((HTMLConfiguration) fConfiguration).evaluateInputSource(in); } finally { page_.registerParsingEnd(); page_.registerInlineSnippetParsingEnd(); } }
/** * Parses and then inserts the specified HTML content into the HTML content currently being parsed. * @param html the HTML content to push */ public void pushInputString(final String html) { page_.registerParsingStart(); page_.registerInlineSnippetParsingStart(); try { final WebResponse webResponse = page_.getWebResponse(); final String charset = webResponse.getContentCharset(); final String url = webResponse.getRequestSettings().getUrl().toString(); final XMLInputSource in = new XMLInputSource(null, url, null, new StringReader(html), charset); ((HTMLConfiguration) fConfiguration).evaluateInputSource(in); } finally { page_.registerParsingEnd(); page_.registerInlineSnippetParsingEnd(); } }
/** * Parses and then inserts the specified HTML content into the HTML content currently being parsed. * @param html the HTML content to push */ public void pushInputString(final String html) { page_.registerParsingStart(); page_.registerInlineSnippetParsingStart(); try { final WebResponse webResponse = page_.getWebResponse(); final String charset = webResponse.getContentCharset(); final String url = webResponse.getRequestSettings().getUrl().toString(); final XMLInputSource in = new XMLInputSource(null, url, null, new StringReader(html), charset); ((HTMLConfiguration) fConfiguration).evaluateInputSource(in); } finally { page_.registerParsingEnd(); page_.registerInlineSnippetParsingEnd(); } }
/** * Parses and then inserts the specified HTML content into the HTML content currently being parsed. * @param html the HTML content to push */ public void pushInputString(final String html) { page_.registerParsingStart(); page_.registerInlineSnippetParsingStart(); try { final WebResponse webResponse = page_.getWebResponse(); final String charset = webResponse.getContentCharset(); final String url = webResponse.getRequestSettings().getUrl().toString(); final XMLInputSource in = new XMLInputSource(null, url, null, new StringReader(html), charset); ((HTMLConfiguration) fConfiguration).evaluateInputSource(in); } finally { page_.registerParsingEnd(); page_.registerInlineSnippetParsingEnd(); } }
/** * Builds a WebResponse with new content, preserving all other information. * @param wr the web response to adapt * @param newContent the new content to place in the response * @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 WebResponse(wrd, wr.getWebRequest().getUrl(), wr.getWebRequest().getHttpMethod(), wr.getLoadTime()); }
/** * Builds a WebResponse with new content, preserving all other information. * @param wr the web response to adapt * @param newContent the new content to place in the response * @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()); }
/** * Builds a WebResponse with new content, preserving all other information. * @param wr the web response to adapt * @param newContent the new content to place in the response * @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()); }
/** * Builds a WebResponse with new content, preserving all other information. * @param wr the web response to adapt * @param newContent the new content to place in the response * @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()); }
/** * Builds a WebResponse with new content, preserving all other information. * @param wr the web response to adapt * @param newContent the new content to place in the response * @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 WebResponse(wrd, wr.getWebRequest().getUrl(), wr.getWebRequest().getHttpMethod(), wr.getLoadTime()); }