jsonSimStats: fix null ref when region not found; limite http content lenght; cosmetics

This commit is contained in:
UbitUmarov
2021-09-01 15:45:23 +01:00
parent b363d1f9ee
commit 98afe851ee
6 changed files with 66 additions and 127 deletions

View File

@@ -31,7 +31,7 @@ namespace OSHttpServer
private NameValueCollection m_queryString = null;
private Uri m_uri = null;
private string m_uriPath;
public readonly IHttpClientContext m_context;
public IHttpClientContext m_context;
IPEndPoint m_remoteIPEndPoint = null;
public HttpRequest(IHttpClientContext pContext)
@@ -340,6 +340,8 @@ namespace OSHttpServer
case "content-length":
if (!int.TryParse(value, out int t))
throw new BadRequestException("Invalid content length.");
if (t > 250 * 1024 * 1024)
throw new OSHttpServer.Exceptions.HttpException(HttpStatusCode.RequestEntityTooLarge,"Request Entity Too Large");
ContentLength = t;
break; //todo: maybe throw an exception
case "host":
@@ -458,9 +460,11 @@ namespace OSHttpServer
/// </summary>
public void Clear()
{
if (m_body != null && m_body.CanRead)
if (m_body != null)
{
m_body.Dispose();
m_body = null;
m_body = null;
}
m_contentLength = 0;
m_method = string.Empty;
m_uri = null;
@@ -469,6 +473,7 @@ namespace OSHttpServer
m_headers.Clear();
m_connection = ConnectionType.KeepAlive;
IsAjax = false;
m_context = null;
//_form.Clear();
}