Send content lengths

This commit is contained in:
Frank A. Krueger 2017-06-12 18:37:41 -07:00
parent 176de592cc
commit e6288e4ca7
1 changed files with 7 additions and 7 deletions

View File

@ -79,6 +79,7 @@ namespace Ooui
response.ContentLength64 = clientJsBytes.LongLength; response.ContentLength64 = clientJsBytes.LongLength;
response.ContentType = "application/javascript"; response.ContentType = "application/javascript";
response.ContentEncoding = Encoding.UTF8; response.ContentEncoding = Encoding.UTF8;
response.AddHeader ("Cache-Control", "public, max-age=3600");
using (var s = response.OutputStream) { using (var s = response.OutputStream) {
s.Write (clientJsBytes, 0, clientJsBytes.Length); s.Write (clientJsBytes, 0, clientJsBytes.Length);
} }
@ -103,14 +104,13 @@ namespace Ooui
response.StatusCode = 200; response.StatusCode = 200;
response.ContentType = "text/html"; response.ContentType = "text/html";
response.ContentEncoding = Encoding.UTF8; response.ContentEncoding = Encoding.UTF8;
var html = Encoding.UTF8.GetBytes ($@"<html>
<head><title>{element}</title></head>
<body><script src=""/client.js""> </script></body>
</html>");
response.ContentLength64 = html.LongLength;
using (var s = response.OutputStream) { using (var s = response.OutputStream) {
using (var w = new StreamWriter (s, Encoding.UTF8)) { s.Write (html, 0, html.Length);
w.WriteLine ($"<html><head>");
w.WriteLine ($"<title>{element}</title>");
w.WriteLine ($"</head><body>");
w.WriteLine ($"<script src=\"/client.js\"> </script>");
w.WriteLine ($"<body></html>");
}
} }
response.Close (); response.Close ();
} }