fix HttpGet method

This commit is contained in:
Evil Factory
2022-06-22 20:38:49 -03:00
parent 814870d80c
commit a154558f0b
@@ -156,7 +156,7 @@ namespace Barotrauma
} }
#endif #endif
public void HttpRequest(string url, LuaCsAction callback, string data, string method = "POST", string contentType = "application/json") public void HttpRequest(string url, LuaCsAction callback, string data = null, string method = "POST", string contentType = "application/json")
{ {
try try
{ {
@@ -164,8 +164,11 @@ namespace Barotrauma
httpWebRequest.ContentType = contentType; httpWebRequest.ContentType = contentType;
httpWebRequest.Method = method; httpWebRequest.Method = method;
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) if (data != null)
streamWriter.Write(data); {
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
streamWriter.Write(data);
}
httpWebRequest.BeginGetResponse(new AsyncCallback((IAsyncResult result) => httpWebRequest.BeginGetResponse(new AsyncCallback((IAsyncResult result) =>
{ {
@@ -197,9 +200,9 @@ namespace Barotrauma
} }
public void HttpGet(string url, LuaCsAction callback, string data, string contentType = "application/json") public void HttpGet(string url, LuaCsAction callback)
{ {
HttpRequest(url, callback, data, "GET", contentType); HttpRequest(url, callback, null, "GET");
} }
public static async void HandleIncomingConnections(System.Net.HttpListener listener, LuaCsAction onRequestReceived) public static async void HandleIncomingConnections(System.Net.HttpListener listener, LuaCsAction onRequestReceived)