Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebResponse.getContentAsString() fails to handle brotli stream data #175

Closed
RuralHunter opened this issue May 27, 2020 · 0 comments
Closed

Comments

@RuralHunter
Copy link
Contributor

This is the test case to show the problem, most of it is copied from WebResponseDataTest:

@Test
    public void testWebResponse() throws Exception
    {
        final InputStream stream = getClass().getClassLoader().getResourceAsStream("testfiles/test.html.brotli");
        final byte[] zippedContent = IOUtils.toByteArray(stream);

        final List<com.gargoylesoftware.htmlunit.util.NameValuePair> headers = new ArrayList<>();
        headers.add(new com.gargoylesoftware.htmlunit.util.NameValuePair("Content-Encoding", "br"));

        final WebResponseData data = new WebResponseData(zippedContent, HttpStatus.SC_OK, "OK", headers);
        WebResponse response=new WebResponse(data,new URL("http://test.com"),HttpMethod.GET,1000);
        logger.info("content string:{}", response.getContentAsString());
        logger.info("body:{}", new String(data.getBody(), UTF_8));
    }

Just compare the output of the last 2 lines.

@rbri rbri closed this as completed in 9d5c33b May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant