SendFileResponse as now the default parameter folder = "resources"
add a function GetPostParams
This commit is contained in:
parent
b8fb0e7278
commit
b3d60ad1ae
@ -37,6 +37,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
using BlubbFish.Utils.IoT.Connector;
|
using System;
|
||||||
using BlubbFish.Utils.IoT.Events;
|
|
||||||
using LitJson;
|
|
||||||
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;
|
||||||
using System.Threading.Tasks;
|
using System.Web;
|
||||||
|
using BlubbFish.Utils.IoT.Connector;
|
||||||
|
using BlubbFish.Utils.IoT.Events;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.Utils.IoT.Bots
|
namespace BlubbFish.Utils.IoT.Bots {
|
||||||
{
|
|
||||||
public abstract class Webserver
|
public abstract class Webserver
|
||||||
{
|
{
|
||||||
protected Dictionary<String, String> config;
|
protected Dictionary<String, String> config;
|
||||||
@ -42,7 +40,7 @@ namespace BlubbFish.Utils.IoT.Bots
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean SendFileResponse(HttpListenerContext cont, String folder) {
|
public static Boolean SendFileResponse(HttpListenerContext cont, String folder = "resources") {
|
||||||
String restr = cont.Request.Url.PathAndQuery;
|
String restr = cont.Request.Url.PathAndQuery;
|
||||||
if(restr.StartsWith("/")) {
|
if(restr.StartsWith("/")) {
|
||||||
if(restr.IndexOf("?") != -1) {
|
if(restr.IndexOf("?") != -1) {
|
||||||
@ -111,6 +109,26 @@ namespace BlubbFish.Utils.IoT.Bots
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Dictionary<String, String> GetPostParams(HttpListenerRequest req) {
|
||||||
|
if(req.HttpMethod == "POST") {
|
||||||
|
if(req.HasEntityBody) {
|
||||||
|
StreamReader reader = new StreamReader(req.InputStream, req.ContentEncoding);
|
||||||
|
String rawData = reader.ReadToEnd();
|
||||||
|
req.InputStream.Close();
|
||||||
|
reader.Close();
|
||||||
|
Dictionary<String, String> ret = new Dictionary<String, String>();
|
||||||
|
foreach(String param in rawData.Split('&')) {
|
||||||
|
String[] kvPair = param.Split('=');
|
||||||
|
if(!ret.ContainsKey(kvPair[0])) {
|
||||||
|
ret.Add(kvPair[0], HttpUtility.UrlDecode(kvPair[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Dictionary<String, String>();
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.httplistener.Stop();
|
this.httplistener.Stop();
|
||||||
this.httplistener.Close();
|
this.httplistener.Close();
|
||||||
|
Loading…
Reference in New Issue
Block a user