Wow, load was slow because websocket sends were slow, because TextEcoder was slow. Do it in C.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3796 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-01-27 01:15:54 +00:00
parent 7b32067b07
commit 9fd4be0e4a
6 changed files with 23 additions and 3358 deletions

View File

@ -121,7 +121,7 @@ function authHandler(request, response) {
response.end();
} else {
File.readFile("core/auth.html").then(function(data) {
var html = new TextDecoder("UTF-8").decode(data);
var html = utf8Decode(data);
var contents = "";
if (entry) {

View File

@ -1,8 +1,5 @@
"use strict";
require("encoding-indexes");
require("encoding");
var auth = require("auth");
var app = require("app");

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -200,7 +200,7 @@ function handleWebSocketRequest(request, response, client) {
opCode = 0x2;
}
if (opCode == 0x1 && (typeof message == "string" || message instanceof String)) {
message = new TextEncoder("UTF-8").encode(message);
message = utf8Encode(message);
}
var fin = true;
var packet = [(fin ? (1 << 7) : 0) | (opCode & 0xf)];
@ -291,7 +291,7 @@ function handleWebSocketRequest(request, response, client) {
if (fin) {
if (response.onMessage) {
response.onMessage({
data: frameOpCode == 0x1 ? new TextDecoder("UTF-8").decode(frame) : frame,
data: frameOpCode == 0x1 ? utf8Decode(frame) : frame,
opCode: frameOpCode,
});
}
@ -376,7 +376,7 @@ function handleConnection(client) {
function handleLine(line, length) {
if (bodyToRead == -1) {
line = new TextDecoder("ASCII").decode(line);
line = utf8Decode(line);
if (!request) {
request = line.split(' ');
return true;
@ -406,7 +406,7 @@ function handleConnection(client) {
}
}
} else {
line = new TextDecoder("UTF-8").decode(line);
line = utf8Decode(line);
body += line;
bodyToRead -= length;
if (bodyToRead <= 0) {
@ -489,8 +489,8 @@ if (tildefriends.https_port) {
tls.keyStat.mtime != stat[1].mtime ||
tls.keyStat.size != stat[1].size) {
print("Reloading " + kCertificatePath + " and " + kPrivateKeyPath);
var privateKey = new TextDecoder("ASCII").decode(await File.readFile(kPrivateKeyPath));
var certificate = new TextDecoder("ASCII").decode(await File.readFile(kCertificatePath));
var privateKey = utf8Decode(await File.readFile(kPrivateKeyPath));
var certificate = utf8Decode(await File.readFile(kCertificatePath));
tls.context = new TlsContext();
tls.context.setPrivateKey(privateKey);