Attaching files to posts sort of works. Whew.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3799 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-01-28 03:11:09 +00:00
parent e84ced6f79
commit d77c452120
6 changed files with 53 additions and 5 deletions

View File

@ -390,7 +390,7 @@ function handleConnection(client) {
if (headers["content-length"] != undefined) {
bodyToRead = parseInt(headers["content-length"]);
lineByLine = false;
body = "";
body = new Uint8Array(bodyToRead);
return true;
} else if (headers["connection"]
&& headers["connection"].toLowerCase().split(",").map(x => x.trim()).indexOf("upgrade") != -1
@ -406,9 +406,12 @@ function handleConnection(client) {
}
}
} else {
line = utf8Decode(line);
body += line;
bodyToRead -= length;
var offset = body.length - bodyToRead;
if (line.length > body.length - offset) {
line = line.slice(0, body.length - offset);
}
body.set(line, offset);
bodyToRead -= line.length;
if (bodyToRead <= 0) {
finish();
}