Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/mono/sample/wasm/browser-bench/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class MainApp {
setExclusions(exclusions.join(','));
}

const r = await fetch("/bootstrap.flag", {
const r = await fetch("/rewrite=bootstrap.flag", {
method: 'POST',
body: "ok"
});
Expand All @@ -96,15 +96,19 @@ class MainApp {
if (resultString.length == 0) break;
document.getElementById("out").innerHTML += resultString;
console.log(resultString);
await fetch("/log=bench-log.txt", {
method: 'POST',
body: resultString
});
}

document.getElementById("out").innerHTML += "Finished";
const r1 = await fetch("/results.json", {
const r1 = await fetch("/rewrite=results.json", {
method: 'POST',
body: getFullJsonResults()
});
console.log("post request complete, response: ", r1);
const r2 = await fetch("/results.html", {
const r2 = await fetch("/rewrite=results.html", {
method: 'POST',
body: document.getElementById("out").innerHTML
});
Expand Down
25 changes: 23 additions & 2 deletions src/mono/sample/wasm/simple-server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,32 @@ private async void ReceivePostAsync(HttpListenerContext context)
if (contentType != null && contentType.StartsWith("text/plain") && path.StartsWith("/"))
{
path = path.Substring(1);
var split = path.Split('=');
string cmd;
if (split.Length > 1)
{
cmd = split[0];
path = split[1];
} else
cmd = "rewrite";

if (Verbose)
Console.WriteLine($" writting POST stream to '{path}' file");
Console.WriteLine($" POST cmd: {cmd} path: '{path}'");

var content = await new StreamReader(context.Request.InputStream).ReadToEndAsync().ConfigureAwait(false);
await File.WriteAllTextAsync(path, content).ConfigureAwait(false);

switch (cmd) {
case "rewrite":
await File.WriteAllTextAsync(path, content).ConfigureAwait(false);
break;
case "log":
await File.AppendAllTextAsync(path, content + "\n").ConfigureAwait(false);
Console.WriteLine($" log: {content}");
break;
default:
Console.WriteLine($" unknown command: {cmd}");
break;
}
}
else
return;
Expand Down