better support of raw data transfer

This commit is contained in:
Pilzinsel64
2025-03-18 08:56:08 +01:00
parent 86154e93af
commit 24cde0bd03
3 changed files with 21 additions and 1 deletions

View File

@@ -411,6 +411,7 @@ public class ApiServer : IApiServer
else if (result.ResultContent is byte[] resultBytes)
{
Log.Info("Sending raw bytes response for " + context.Request.RawUrl);
context.Response.ContentType = "application/octet-stream";
context.Response.OutputStream.Write(resultBytes, 0, resultBytes.Length);
context.Response.OutputStream.Flush();
}
@@ -455,6 +456,10 @@ public class ApiServer : IApiServer
if (result.Message is null)
return new(result, null);
// Return result with raw data
if (result.Message is ApiRawMessage dataMsg)
return new(result, dataMsg.Data);
// Serializer
Log.Debug("Serialize message");
if (serializer.Serialize(result.Message) is not string resultStr)