From 24a96c282946f85e47f279d5320c406ecada129d Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Mon, 6 Jan 2020 18:28:29 -0800 Subject: [PATCH] Fix Commands POST Action. --- Server/API/CommandsController.cs | 48 +++++++++++++++++--------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/Server/API/CommandsController.cs b/Server/API/CommandsController.cs index ebc3bf20..14a9f654 100644 --- a/Server/API/CommandsController.cs +++ b/Server/API/CommandsController.cs @@ -99,31 +99,35 @@ namespace Remotely.Server.API } [HttpPost("{resultType}")] - public void Post(string resultType) + public async Task Post(string resultType) { - var content = new StreamReader(Request.Body).ReadToEnd(); - switch (resultType) + using (var sr = new StreamReader(Request.Body)) { - case "PSCore": - { - var result = JsonConvert.DeserializeObject(content); - var commandContext = DataService.GetCommandContext(result.CommandContextID); - commandContext.PSCoreResults.Add(result); - DataService.AddOrUpdateCommandContext(commandContext); + var content = await sr.ReadToEndAsync(); + switch (resultType) + { + case "PSCore": + { + var result = JsonConvert.DeserializeObject(content); + var commandContext = DataService.GetCommandContext(result.CommandContextID); + commandContext.PSCoreResults.Add(result); + DataService.AddOrUpdateCommandContext(commandContext); + break; + } + case "WinPS": + case "CMD": + case "Bash": + { + var result = JsonConvert.DeserializeObject(content); + var commandContext = DataService.GetCommandContext(result.CommandContextID); + commandContext.CommandResults.Add(result); + DataService.AddOrUpdateCommandContext(commandContext); + break; + } + default: break; - } - case "WinPS": - case "CMD": - case "Bash": - { - var result = JsonConvert.DeserializeObject(content); - var commandContext = DataService.GetCommandContext(result.CommandContextID); - commandContext.CommandResults.Add(result); - DataService.AddOrUpdateCommandContext(commandContext); - break; - } - default: - break; + } + } } }