chaosdorf / labello

my little brother, printing is magic!
MIT License
14 stars 3 forks source link

error pages look weird #23

Open YtvwlD opened 3 years ago

YtvwlD commented 3 years ago

We're starting the response too early, so when we transmit an error page, it won't be rendered correctly.

As an example, the timeout error looks like this:

POST OK.
start printing: foo
HTTP/1.0 500 ERROR: timed out
Server: BaseHTTP/0.6 Python/3.8.10
Date: Tue, 24 Aug 2021 16:18:10 GMT
Connection: close
Content-Type: text/html;charset=utf-8
Content-Length: 453

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: 500</p>
        <p>Message: ERROR: timed out.</p>
        <p>Error code explanation: 500 - Server got itself in trouble.</p>
    </body>
</html>

If we don't send the first two lines, we'll get the HTML rendered.

YtvwlD commented 3 years ago

(This looks simple at first, but this is a major architectural problem. We're printing and rendering the "page" at the same time. If we'd use a rest api or such, we could display progress nicer.)