Add Server header, connection close and urldecode on get params

This commit is contained in:
Mike Nolan 2022-06-22 15:03:20 -05:00
parent 68bf4deb21
commit 340c8ae946
3 changed files with 8 additions and 5 deletions

View File

@ -23,6 +23,8 @@ namespace Tesses.WebServer
RequestHeaders = headers; RequestHeaders = headers;
ResponseHeaders = new Dictionary<string, List<string>>(); ResponseHeaders = new Dictionary<string, List<string>>();
QueryParams = new Dictionary<string, List<string>>(); QueryParams = new Dictionary<string, List<string>>();
ResponseHeaders.Add("Server","Tesses.WebServer");
ResponseHeaders.Add("Connection","close");
RawUrl=path; RawUrl=path;
StatusCode = 200; StatusCode = 200;
@ -64,7 +66,7 @@ namespace Tesses.WebServer
string value = ""; string value = "";
if (itemSplit.Length == 2) if (itemSplit.Length == 2)
{ {
value = itemSplit[1]; value = WebUtility.UrlDecode( itemSplit[1]);
} }
QueryParams.Add(key, value); QueryParams.Add(key, value);
} }

View File

@ -70,7 +70,7 @@ namespace Tesses.WebServer
{ {
//ctx.StatusCode = 200; //ctx.StatusCode = 200;
int start = 0, end = (int)strm.Length - 1; int start = 0, end = (int)strm.Length - 1;
if (ctx.RequestHeaders.ContainsKey(BYTES_RANGE_HEADER)) if (ctx.RequestHeaders.ContainsKey(BYTES_RANGE_HEADER) && strm.CanSeek)
{ {
if (ctx.RequestHeaders[BYTES_RANGE_HEADER].Count > 1) if (ctx.RequestHeaders[BYTES_RANGE_HEADER].Count > 1)
{ {
@ -100,6 +100,7 @@ namespace Tesses.WebServer
{ {
try try
{ {
if(strm.CanSeek)
strm.Position = start; strm.Position = start;
strm.CopyTo(ctx.NetworkStream, Math.Min(8 * 1024 * 1024, end - start + 1)); strm.CopyTo(ctx.NetworkStream, Math.Min(8 * 1024 * 1024, end - start + 1));
} }

View File

@ -5,9 +5,9 @@
<PackageId>Tesses.WebServer</PackageId> <PackageId>Tesses.WebServer</PackageId>
<Author>Mike Nolan</Author> <Author>Mike Nolan</Author>
<Company>Tesses</Company> <Company>Tesses</Company>
<Version>1.0.3.3</Version> <Version>1.0.3.4</Version>
<AssemblyVersion>1.0.3.3</AssemblyVersion> <AssemblyVersion>1.0.3.4</AssemblyVersion>
<FileVersion>1.0.3.3</FileVersion> <FileVersion>1.0.3.4</FileVersion>
<Description>A TCP Listener HTTP(s) Server</Description> <Description>A TCP Listener HTTP(s) Server</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>HTTP, WebServer, Website</PackageTags> <PackageTags>HTTP, WebServer, Website</PackageTags>