Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 9e7e08f

Browse files
Adding functionality to the TestWebServer to handle usage reporting
1 parent ff3fa10 commit 9e7e08f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/tests/TestWebServer/HttpServer.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,29 @@ public void Abort()
100100

101101
private void Process(HttpListenerContext context)
102102
{
103-
Logger.Info($"Handling request");
103+
Logger.Info("Handling request {0}", context.Request.Url.AbsolutePath);
104+
105+
if (context.Request.Url.AbsolutePath == "/api/usage/unity")
106+
{
107+
context.Response.StatusCode = (int)HttpStatusCode.OK;
108+
109+
var streamWriter = new StreamWriter(context.Response.OutputStream);
110+
streamWriter.Write("Cool Unity usage bro!");
111+
streamWriter.Flush();
112+
113+
context.Response.Close();
114+
return;
115+
}
104116

105117
var filename = context.Request.Url.AbsolutePath;
106-
Logger.Info($"{filename}");
107118
filename = filename.TrimStart('/');
108119
filename = filename.Replace('/', Path.DirectorySeparatorChar);
109120
filename = Path.Combine(rootDirectory, filename);
110121

111122
if (!File.Exists(filename))
112123
{
113124
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
125+
Logger.Info($"Path not found - Returning 404");
114126
context.Response.Close();
115127
return;
116128
}

0 commit comments

Comments
 (0)