Merge
This commit is contained in:
parent
bd14722791
commit
2828fec316
@ -113,15 +113,23 @@ public partial class Server : GlobalBase
|
|||||||
if (!request.HasEntityBody)
|
if (!request.HasEntityBody)
|
||||||
{
|
{
|
||||||
Log("No request body");
|
Log("No request body");
|
||||||
Dictionary<string, string> emptyBody = new();
|
return new Dictionary<string, string>();
|
||||||
return emptyBody;
|
|
||||||
}
|
}
|
||||||
Stream body = request.InputStream;
|
Stream body = request.InputStream;
|
||||||
Encoding encoding = request.ContentEncoding;
|
Encoding encoding = request.ContentEncoding;
|
||||||
StreamReader reader = new StreamReader(body, encoding);
|
using StreamReader streamReader = new (body, encoding);
|
||||||
string s = reader.ReadToEnd();
|
try
|
||||||
Dictionary<string, string> requestBody = JsonConvert.DeserializeObject<Dictionary<string, string>>(s);
|
{
|
||||||
return requestBody;
|
Dictionary<string, string> requestBody =
|
||||||
|
JsonConvert.DeserializeObject<Dictionary<string, string>>(streamReader.ReadToEnd())
|
||||||
|
?? new();
|
||||||
|
return requestBody;
|
||||||
|
}
|
||||||
|
catch (JsonException e)
|
||||||
|
{
|
||||||
|
Log(e.Message);
|
||||||
|
}
|
||||||
|
return new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleGet(HttpListenerRequest request, HttpListenerResponse response)
|
private void HandleGet(HttpListenerRequest request, HttpListenerResponse response)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace Tranga;
|
namespace Tranga;
|
||||||
|
|
||||||
@ -29,30 +27,6 @@ public partial class Server
|
|||||||
SendResponse(responseMessage.Item1, response, responseMessage.Item2);
|
SendResponse(responseMessage.Item1, response, responseMessage.Item2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, string> GetRequestBody(HttpListenerRequest request)
|
|
||||||
{
|
|
||||||
if (!request.HasEntityBody)
|
|
||||||
{
|
|
||||||
Log("No request body");
|
|
||||||
return new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
Stream body = request.InputStream;
|
|
||||||
Encoding encoding = request.ContentEncoding;
|
|
||||||
using StreamReader streamReader = new (body, encoding);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, string> requestBody =
|
|
||||||
JsonConvert.DeserializeObject<Dictionary<string, string>>(streamReader.ReadToEnd())
|
|
||||||
?? new();
|
|
||||||
return requestBody;
|
|
||||||
}
|
|
||||||
catch (JsonException e)
|
|
||||||
{
|
|
||||||
Log(e.Message);
|
|
||||||
}
|
|
||||||
return new Dictionary<string, string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ValueTuple<HttpStatusCode, object?> HandleGetV2(string path, HttpListenerResponse response,
|
private ValueTuple<HttpStatusCode, object?> HandleGetV2(string path, HttpListenerResponse response,
|
||||||
Dictionary<string, string> requestParameters)
|
Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user