diff --git a/MTSC.UnitTests/HttpRequestTests.cs b/MTSC.UnitTests/HttpRequestTests.cs
new file mode 100644
index 0000000..bc29397
--- /dev/null
+++ b/MTSC.UnitTests/HttpRequestTests.cs
@@ -0,0 +1,38 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using MTSC.Common.Http;
+using System.Text;
+
+namespace MTSC.UnitTests
+{
+ [TestClass]
+ public class HttpRequestTests
+ {
+ private const string postWithHeader = "POST /test/demo_form.php HTTP/1.1\n\rHost: w3schools.com\n\r\n\r";
+
+ private const string emptyGet = "GET / HTTP/1.1\n\r\n\r";
+
+ [DataTestMethod]
+ [DataRow(postWithHeader)]
+ [DataRow(emptyGet)]
+ public void ParseShouldPass(string requestString)
+ {
+ HttpRequest request = HttpRequest.FromBytes(ASCIIEncoding.ASCII.GetBytes(requestString));
+ }
+
+ [DataTestMethod]
+ [DataRow(postWithHeader, "test/demo_form.php")]
+ [DataRow(emptyGet, "")]
+ public void UriShouldBeAsExpected(string requestString, string uri)
+ {
+ HttpRequest request = HttpRequest.FromBytes(ASCIIEncoding.ASCII.GetBytes(requestString));
+ Assert.AreEqual(request.RequestURI, uri);
+ }
+
+ [TestMethod]
+ public void HeaderShouldExist()
+ {
+ HttpRequest request = HttpRequest.FromBytes(ASCIIEncoding.ASCII.GetBytes(postWithHeader));
+ Assert.AreEqual(request.Headers[HttpMessage.RequestHeaders.Host], "w3schools.com");
+ }
+ }
+}
diff --git a/MTSC/Common/Http/HttpRequest.cs b/MTSC/Common/Http/HttpRequest.cs
index e1e71a6..aa51e15 100644
--- a/MTSC/Common/Http/HttpRequest.cs
+++ b/MTSC/Common/Http/HttpRequest.cs
@@ -107,6 +107,7 @@ namespace MTSC.Common.Http
* Get each character one by one. When meeting a SP character, parse the URI and clear the buffer.
*/
StringBuilder parseBuffer = new StringBuilder();
+ ms.ReadByte(); //Ignore the first '/'
while (ms.Position < ms.Length)
{
try
diff --git a/MTSC/MTSC.csproj b/MTSC/MTSC.csproj
index 9aec25f..0cde73b 100644
--- a/MTSC/MTSC.csproj
+++ b/MTSC/MTSC.csproj
@@ -5,12 +5,12 @@
netcoreapp2.1;net48;netstandard2.0;netcoreapp3.0
- 1.5.6
+ 1.5.7
Alexandru-Victor Macocian
MTSC
Modular TCP Server and Client
- 0.1.5.6
- 0.1.5.6
+ 0.1.5.7
+ 0.1.5.7
true
AnyCPU;x64
https://github.com/AlexMacocian/MTSC
diff --git a/MTSC/Server/Handlers/HttpHandler.cs b/MTSC/Server/Handlers/HttpHandler.cs
index 4d735db..82ae926 100644
--- a/MTSC/Server/Handlers/HttpHandler.cs
+++ b/MTSC/Server/Handlers/HttpHandler.cs
@@ -4,9 +4,6 @@ using MTSC.Exceptions;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using static MTSC.Common.Http.HttpMessage;
namespace MTSC.Server.Handlers
{