quick fix errorwhen parsing invalid http header
This commit is contained in:
parent
69a11814ac
commit
568b0a48fe
@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using DiIiS_NA.Core.Logging;
|
||||||
|
|
||||||
namespace DiIiS_NA.REST.Http
|
namespace DiIiS_NA.REST.Http
|
||||||
{
|
{
|
||||||
@ -87,27 +88,34 @@ namespace DiIiS_NA.REST.Http
|
|||||||
|
|
||||||
while (!sr.EndOfStream)
|
while (!sr.EndOfStream)
|
||||||
{
|
{
|
||||||
info = sr.ReadLine().Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries);
|
try
|
||||||
|
|
||||||
if (info.Length == 2)
|
|
||||||
headerValues.Add(info[0].Replace("-", "").ToLower(), info[1]);
|
|
||||||
else if (info.Length > 2)
|
|
||||||
{
|
{
|
||||||
var val = "";
|
info = sr.ReadLine().Split(new string[] { ": " }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
info.Skip(1);
|
if (info.Length == 2)
|
||||||
|
headerValues.Add(info[0].Replace("-", "").ToLower(), info[1]);
|
||||||
|
else if (info.Length > 2)
|
||||||
|
{
|
||||||
|
var val = "";
|
||||||
|
|
||||||
headerValues.Add(info[0].Replace("-", "").ToLower(), val);
|
info.Skip(1);
|
||||||
|
|
||||||
|
headerValues.Add(info[0].Replace("-", "").ToLower(), val);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We are at content here.
|
||||||
|
var content = sr.ReadLine();
|
||||||
|
|
||||||
|
headerValues.Add("content", content);
|
||||||
|
|
||||||
|
// There shouldn't be anything after the content!
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// We are at content here.
|
return null;
|
||||||
var content = sr.ReadLine();
|
|
||||||
|
|
||||||
headerValues.Add("content", content);
|
|
||||||
|
|
||||||
// There shouldn't be anything after the content!
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
user.block.title