adjusts http get interface to not accept args on get commands
and to clean up the uri
This commit is contained in:
parent
c7d8429eef
commit
e93a82b6e8
1 changed files with 6 additions and 12 deletions
|
|
@ -7,6 +7,7 @@ using BSB.bottypes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
@ -100,26 +101,19 @@ namespace BetterSecondBot.HttpServer
|
||||||
HttpListenerRequest req = ctx.Request;
|
HttpListenerRequest req = ctx.Request;
|
||||||
HttpListenerResponse resp = ctx.Response;
|
HttpListenerResponse resp = ctx.Response;
|
||||||
string test = req.Url.AbsolutePath.Substring(1);
|
string test = req.Url.AbsolutePath.Substring(1);
|
||||||
string[] http_args = test.Split('/', StringSplitOptions.RemoveEmptyEntries);
|
test = test.Replace(Config.HttpPublicUrlBase, "");
|
||||||
|
List<string> http_args = test.Split('/', StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
byte[] data = Encoding.UTF8.GetBytes("totaly fucked");
|
byte[] data = Encoding.UTF8.GetBytes("totaly fucked");
|
||||||
resp.StatusCode = 404;
|
resp.StatusCode = 404;
|
||||||
if (req.HttpMethod == "GET")
|
if (req.HttpMethod == "GET")
|
||||||
{
|
{
|
||||||
resp.StatusCode = 200;
|
resp.StatusCode = 200;
|
||||||
string command = "status";
|
string command = "status";
|
||||||
string arg = "";
|
if (http_args.Count > 0)
|
||||||
if (helpers.notempty(http_args) == true)
|
|
||||||
{
|
{
|
||||||
if (http_args.Length >= 1)
|
command = http_args.Last();
|
||||||
{
|
|
||||||
command = http_args[0];
|
|
||||||
}
|
}
|
||||||
if (http_args.Length == 2)
|
string content = String.Join("{@}", get_controler.Call(command, ""));
|
||||||
{
|
|
||||||
arg = http_args[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
string content = String.Join("{@}", get_controler.Call(command, arg));
|
|
||||||
data = Encoding.UTF8.GetBytes(content);
|
data = Encoding.UTF8.GetBytes(content);
|
||||||
}
|
}
|
||||||
else if (req.HttpMethod == "POST")
|
else if (req.HttpMethod == "POST")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue