file cache seems done
This commit is contained in:
parent
46aacfb621
commit
d26cb75331
@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>QHL: 404</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>404 Not Found</h1>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>QHL: 500</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>500 Internal Server Error</h1>
|
||||
</body>
|
||||
</html>
|
||||
@ -283,8 +283,7 @@ handle_entry(Socket, Entry) ->
|
||||
respond(Socket, Response).
|
||||
|
||||
http_err(Socket, 404) ->
|
||||
HtmlPath = filename:join([zx:get_home(), "priv", "404.html"]),
|
||||
{ok, ResponseBody} = file:read_file(HtmlPath),
|
||||
ResponseBody = bdy_404(),
|
||||
Headers = [{"content-type", "text/html"}],
|
||||
Response = #response{headers = Headers,
|
||||
code = 404,
|
||||
@ -292,8 +291,7 @@ http_err(Socket, 404) ->
|
||||
respond(Socket, Response);
|
||||
% default error is 500
|
||||
http_err(Socket, _) ->
|
||||
HtmlPath = filename:join([zx:get_home(), "priv", "500.html"]),
|
||||
{ok, ResponseBody} = file:read_file(HtmlPath),
|
||||
ResponseBody = bdy_500(),
|
||||
Headers = [{"content-type", "text/html"}],
|
||||
Response = #response{headers = Headers,
|
||||
code = 500,
|
||||
@ -301,6 +299,32 @@ http_err(Socket, _) ->
|
||||
respond(Socket, Response).
|
||||
|
||||
|
||||
bdy_404() ->
|
||||
["<!DOCTYPE html>"
|
||||
"<html lang=\"en\">"
|
||||
"<head>"
|
||||
"<meta charset=\"UTF-8\">"
|
||||
"<title>QHL: 404</title>"
|
||||
"</head>"
|
||||
"<body>"
|
||||
"<h1>404 Not Found</h1>"
|
||||
"</body>"
|
||||
"</html>"].
|
||||
|
||||
|
||||
bdy_500() ->
|
||||
["<!DOCTYPE html>"
|
||||
"<html lang=\"en\">"
|
||||
"<head>"
|
||||
"<meta charset=\"UTF-8\">"
|
||||
"<title>QHL: 500 Internal Server Error</title>"
|
||||
"</head>"
|
||||
"<body>"
|
||||
"<h1>500 Internal Server Error</h1>"
|
||||
"</body>"
|
||||
"</html>"].
|
||||
|
||||
|
||||
respond(Socket, R = #response{code = Code, headers = Headers, body = Body}) ->
|
||||
Slogan = slogan(Code),
|
||||
BodyBytes = iolist_to_binary(Body),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user