mirror of
https://github.com/AlexMacocian/MTSC.git
synced 2026-07-15 14:59:33 +00:00
Fix message assembly when a request is truncated (#9)
This commit is contained in:
@@ -403,31 +403,20 @@ namespace MTSC.Common.Http
|
||||
}
|
||||
|
||||
this.HeaderByteCount = (int)ms.Position;
|
||||
if (this.Headers.ContainsHeader(EntityHeaders.ContentLength))
|
||||
this.Body = ms.ReadRemainingBytes();
|
||||
if (this.Headers.ContainsHeader(EntityHeaders.ContentLength) is false)
|
||||
{
|
||||
var remainingBytes = int.Parse(this.Headers[EntityHeaders.ContentLength]);
|
||||
if (remainingBytes <= ms.Length - ms.Position)
|
||||
{
|
||||
this.Body = ms.ReadRemainingBytes();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ms.Length - ms.Position > 1)
|
||||
{
|
||||
/*
|
||||
* If the message contains a body, copy it into a different array
|
||||
* and save it into the HTTP message;
|
||||
*/
|
||||
this.Body = ms.ReadRemainingBytes();
|
||||
}
|
||||
|
||||
this.Complete = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var contentLength = int.Parse(this.Headers[EntityHeaders.ContentLength]);
|
||||
if (this.Body.Length >= contentLength)
|
||||
{
|
||||
this.Complete = true;
|
||||
}
|
||||
|
||||
this.Complete = true;
|
||||
return;
|
||||
}
|
||||
private string GetField(byte[] buffer, ref int index)
|
||||
|
||||
+2
-2
@@ -10,8 +10,8 @@
|
||||
<Authors>Alexandru-Victor Macocian</Authors>
|
||||
<Product>MTSC</Product>
|
||||
<Description>Modular TCP Server and Client</Description>
|
||||
<AssemblyVersion>5.1.1.0</AssemblyVersion>
|
||||
<FileVersion>5.1.1.0</FileVersion>
|
||||
<AssemblyVersion>5.1.2.0</AssemblyVersion>
|
||||
<FileVersion>5.1.2.0</FileVersion>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<PackageProjectUrl>https://github.com/AlexMacocian/MTSC</PackageProjectUrl>
|
||||
|
||||
Reference in New Issue
Block a user