Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
![WebExpress](https://raw.githubusercontent.com/ReneSchwarzer/WebExpress.Doc/main/assets/banner.png)

# WebExpress
A lightweight web server for use in .net applications.
WebExpress is a lightweight web server optimized for use in low-performance environments (e.g. Rasperry PI). By providing
a powerful plugin system and a comprehensive API, web applications can be easily and quickly integrated into a .net
language (e.g. C#). Some advantages of WebExpress are:

- It is easy to use.
- It offers a variety of features and tools that can help you build and manage your website.
- It is fast and efficient and can help you save time and money.
- It is flexible and can be customized to meet your specific requirements.

The WebExpress family includes the following projects:

- [WebExpress (core)](https://github.com/ReneSchwarzer/WebExpress#readme) - This project. The core for WebExpress applications.
- [WebExpress.WebUI](https://github.com/ReneSchwarzer/WebExpress.WebUI#readme) - Common templates and controls for WebExpress applications.
- [WebExpress.WebIndex](https://github.com/ReneSchwarzer/WebExpress.WebIndex#readme) - Reverse index for WebExpress applications.
- [WebExpress.WebApp](https://github.com/ReneSchwarzer/WebExpress.WebApp#readme) - Business application template for WebExpress applications.
- [WebExpress.Server](https://github.com/ReneSchwarzer/WebExpress.Server#readme) - The web server for WebExpress applications.

# Start
To get started with WebExpress, use the following links and tutorials.

- [installation guide](https://github.com/ReneSchwarzer/WebExpress.Doc/blob/main/doc/installation_guide.md)
- [development guide](https://github.com/ReneSchwarzer/WebExpress.Doc/blob/main/doc/development_guide.md)

## Tutorials
- [HelloWorld](https://github.com/ReneSchwarzer/WebExpress.Tutorial.HelloWorld#readme)

# Tags
#Raspberry #Raspbian #IoT #NETCore #WebExpress
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions licenses/Net.lic
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The MIT License (MIT)

Copyright(c).NET Foundation and Contributors

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
21 changes: 21 additions & 0 deletions licenses/WebExpress.lic
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021 Ren� Schwarzer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions src/WebExpress.Test/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
92 changes: 92 additions & 0 deletions src/WebExpress.Test/Message/UnitTestGetRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System.IO;
using System.Net.Http;
using Xunit;

namespace WebExpress.Test.Message
{
public class UnitTestGetRequest
{
[Fact]
public void Get_General()
{
var client = new HttpClient();
//client.

//client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

//Stream data = client.OpenRead("http://localhost/");
//StreamReader reader = new StreamReader(data);
//string s = reader.ReadToEnd();
//Console.WriteLine(s);
//data.Close();
//reader.Close();

//using var reader = new BinaryReader(new FileStream(Path.Combine("test", "general.get"), FileMode.Open));
//var request = Request.Create(reader, "127.0.0.1");

//Assert.True
//(
// request.Uri?.ToString() == "/abc/xyz/A7BCCCA9-4C7E-4117-9EE2-ECC3381B605A",
// "Fehler in der Funktion Get_General"
//);
}

[Fact]
public void Get_Less()
{
//using var reader = new BinaryReader(new FileStream(Path.Combine("test", "less.get"), FileMode.Open));
//var request = Request.Create(reader, "127.0.0.1");

//Assert.True
//(
// request.Uri?.ToString() == "/abc/xyz/A7BCCCA9-4C7E-4117-9EE2-ECC3381B605A",
// "Fehler in der Funktion Get_Less"
//);
}

[Fact]
public void Get_Massive()
{
//using var reader = new BinaryReader(new FileStream(Path.Combine("test", "massive.get"), FileMode.Open));
//var request = Request.Create(reader, "127.0.0.1");

//Assert.True
//(
// request.Uri?.ToString() == "/abc/xyz/A7BCCCA9-4C7E-4117-9EE2-ECC3381B605A",
// "Fehler in der Funktion Get_Massive"
//);
}

[Fact]
public void Get_Param()
{
//using var reader = new BinaryReader(new FileStream(Path.Combine("test", "param.get"), FileMode.Open));
//var request = Request.Create(reader, "127.0.0.1");
//var param = request?.GetParameter("a")?.Value;

//Assert.True
//(
// request.Uri?.ToString() == "/abc/xyz/A7BCCCA9-4C7E-4117-9EE2-ECC3381B605A" &&
// param != null && param == "1",
// "Fehler in der Funktion Get_Param"
//);
}

[Fact]
public void Get_Param_Umlaut()
{
//using var reader = new BinaryReader(new FileStream(Path.Combine("test", "param_umlaut.get"), FileMode.Open));
//var request = Request.Create(reader, "127.0.0.1");
//var a = request?.GetParameter("a")?.Value;
//var b = request?.GetParameter("b")?.Value;

//Assert.True
//(
// request.Uri?.ToString() == "/abc/xyz/A7BCCCA9-4C7E-4117-9EE2-ECC3381B605A" &&
// a != null && a == "ä" &&
// b != null && b == "ö ü",
// "Fehler in der Funktion Get_Param_Umlaut"
//);
}
}
}
145 changes: 145 additions & 0 deletions src/WebExpress.Test/Message/UnitTestPostRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
namespace WebExpress.Test.Message
{
public class UnitTestPostRequest : UnitTestRequest
{
//[Fact]
//public void Post_TextPlain()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeTextPlain.post"), FileMode.Open));
// var request = Request.Create(reader, "127.0.0.1");
// var param = request?.GetParameter("submit_manufactor")?.Value;

// Assert.True
// (
// param != null && param == "1"
// );
//}

//[Fact]
//public void Post_TextPlain_Umlaut()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeTextPlain_Umlaut.post"), FileMode.Open));
// var request = Request.Create(reader, "127.0.0.1");
// var a = request?.GetParameter("a")?.Value;
// var b = request?.GetParameter("b")?.Value;
// var s = request?.GetParameter("submit_")?.Value;

// Assert.True
// (
// a != null && a == "ä" &&
// b != null && b == "ö ü" &&
// s != null && s == "1"
// );
//}

//[Fact]
//public void Post_Urlencoded()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeXwwwFormUrlencoded.post"), FileMode.Open));
// var request = Request.Create(reader, "127.0.0.1");
// var param = request?.GetParameter("submit_manufactor")?.Value;

// Assert.True
// (
// param != null && param == "1"
// );
//}

//[Fact]
//public void Post_Urlencoded_Umlaut()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeXwwwFormUrlencoded_Umlaut.post"), FileMode.Open));
// var request = Request.Create(reader, "127.0.0.1");
// var a = request?.GetParameter("a")?.Value;
// var b = request?.GetParameter("b")?.Value;
// var s = request?.GetParameter("submit_")?.Value;

// Assert.True
// (
// a != null && a == "ä" &&
// b != null && b == "ö ü" &&
// s != null && s == "1",
// "Fehler in der Funktion Post_Urlencoded_Umlaut"
// );
//}

//[Fact]
//public void Post_Multipart1()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeMultipartFormData1.post"), FileMode.Open));
// var request = Request.Create(reader, "127.0.0.1");
// var param = request?.GetParameter("submit_manufactor")?.Value;

// Assert.True
// (
// param != null && param == "1"
// );
//}

//[Fact]
//public void Post_Multipart2()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeMultipartFormData2.post"), FileMode.Open));
// var request = Request.Create(reader, "127.0.0.1");
// var param = request?.GetParameter("submit_manufactor")?.Value;

// var file = request?.GetParameter("image") as ParameterFile;

// var temp = Path.Combine(Path.GetTempPath(), file.Value);
// File.WriteAllBytes(temp, file.Data);

// Assert.True
// (
// file.Data.Length == 47788 &&
// param != null && param == "1"
// );
//}

//[Fact]
//public void Post_Multipart3()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeMultipartFormData3.post"), FileMode.Open));
// var request = Request.Create(reader, "127.0.0.1");
// var param = request?.GetParameter("submit_del")?.Value;

// Assert.True
// (
// param != null && param == "1"
// );
//}

//[Fact]
//public void Post_Multipart4()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeMultipartFormData4.post"), FileMode.Open));
// var contextFeatures = Prepare(reader, RequestMethod.POST, "");
// var request = new WebMessage.Request(contextFeatures, null, null);
// var param = request?.GetParameter("submit-formular-inventory")?.Value;

// Assert.True
// (
// param != null && param == "1"
// );
//}

//[Fact]
//public void Post_Multipart_Umlaut()
//{
// using var reader = new BinaryReader(new FileStream(Path.Combine("test", "contentTypeMultipartFormData_Umlaut.post"), FileMode.Open));
// var request = Request.Create(reader, "127.0.0.1");
// var a = request?.GetParameter("a")?.Value;
// var b = request?.GetParameter("b")?.Value;
// var s = request?.GetParameter("submit_")?.Value;

// Assert.True
// (
// a != null && a == "ä" &&
// b != null && b == "ö ü" &&
// s != null && s == "1",
// "Fehler in der Funktion Post_Multipart_Umlaut"
// );
//}


}
}
59 changes: 59 additions & 0 deletions src/WebExpress.Test/Message/UnitTestRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Session;
using System.IO;
using System.Net;
using WebExpress.WebMessage;

namespace WebExpress.Test.Message
{
public class UnitTestRequest
{
/// <summary>
/// Erstellt die FeatureCollection
/// </summary>
/// <param name="reader">Die Daten</param>
/// <param name="method">Die Anfragemethode</param>
/// <param name="queryString">Der Querystring</param>
/// <returns>FeatureCollection</returns>
protected static IFeatureCollection Prepare(BinaryReader reader, RequestMethod method, string queryString)
{
var contextFeatures = new FeatureCollection();
contextFeatures.Set<IHttpConnectionFeature>(new HttpConnectionFeature()
{
LocalPort = 80,
LocalIpAddress = IPAddress.Loopback,
RemoteIpAddress = IPAddress.Loopback,
ConnectionId = "43D885B6-DB4D-4EDF-9908-B122A5FFC829"
});
contextFeatures.Set<IHttpRequestFeature>(new HttpRequestFeature()
{
Path = "/",
Protocol = "HTTP/1.1",
Method = method.ToString(),
QueryString = queryString,
Headers = new HeaderDictionary()
});
contextFeatures.Set<IHttpRequestIdentifierFeature>(new HttpRequestIdentifierFeature() { TraceIdentifier = "16FC666F-D7DC-47FF-9FB8-9D0F8DFCEF99" });
contextFeatures.Set<ISessionFeature>(new SessionFeature() { });

var requestFeature = contextFeatures.Get<IHttpRequestFeature>();
requestFeature.Headers.Host = "localhost";
requestFeature.Headers.Connection = "keep-alive";
requestFeature.Headers.ContentType = "";
requestFeature.Headers.ContentLength = 0;
requestFeature.Headers.ContentLanguage = "";
requestFeature.Headers.ContentEncoding = "utf-8";
requestFeature.Headers.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
requestFeature.Headers.AcceptEncoding = "gzip, deflate, br";
requestFeature.Headers.AcceptLanguage = "de,en;q=0.9,en-GB;q=0.8,de-DE;q=0.7,en-US;q=0.6";
requestFeature.Headers.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.50";

//requestFeature.Headers.Cookie;

requestFeature.Headers.Authorization = "";

return contextFeatures;
}
}
}
Loading