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

Main, line 37, sends the raw HTML without begin wrapped in HTTP protocol, returns error in modern Chrome #5

Open
zelmak opened this issue Jun 16, 2019 · 1 comment

Comments

@zelmak
Copy link

zelmak commented Jun 16, 2019

This page isn’t working
localhost sent an invalid response.
ERR_INVALID_HTTP_RESPONSE

Not sure if you want a PR for this series as it would have to apply to all the commits. :)

@zelmak zelmak changed the title Main, line 37, sends the raw HTML without begin wrapped in HTTP protocol, returns error in Chrome Main, line 37, sends the raw HTML without begin wrapped in HTTP protocol, returns error in modern Chrome Jun 16, 2019
@zelmak
Copy link
Author

zelmak commented Jun 16, 2019

To fix this, I changed the code in Main thusly:

        String htmlResponse = router.route(request);

        String httpResponse = 
                "HTTP/1.1 200 OK\n" 
                + "Content-Type: text/html\n"
                + "Content-Length: " + htmlResponse.length() + "\n"
                + "\n"
                + htmlResponse;
        
        s.getOutputStream().write(httpResponse.getBytes());

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