Skip to content

Commit

Permalink
* WaitForRequestBytes this._socket.Poll(0x186a0, SelectMode.SelectRead);
Browse files Browse the repository at this point in the history
  • Loading branch information
shiningrise committed Aug 14, 2014
1 parent 1ac2091 commit 48b170c
Showing 1 changed file with 43 additions and 15 deletions.
58 changes: 43 additions & 15 deletions AspNetServer/HttpProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,61 @@ public HttpProcessor(SimpleHost host, Socket socket)
_socket = socket;
}

public void ProcessRequest()
internal int WaitForRequestBytes()
{
int available = 0;
try
{
RequestInfo requestInfo = ParseRequest();
if (requestInfo != null)
if (this._socket.Available == 0)
{
string staticContentType = GetStaticContentType(requestInfo);
if (!string.IsNullOrEmpty(staticContentType))
this._socket.Poll(0x186a0, SelectMode.SelectRead);
if ((this._socket.Available == 0) && this._socket.Connected)
{
WriteFileResponse(requestInfo.FilePath, staticContentType);
this._socket.Poll(0x1c9c380, SelectMode.SelectRead);
}
else if (requestInfo.FilePath.EndsWith("/"))
}
available = this._socket.Available;
}
catch
{
}
return available;
}

public void ProcessRequest()
{
try
{
if (WaitForRequestBytes() == 0)
{
SendErrorResponse(400);
}
else
{
RequestInfo requestInfo = ParseRequest();
if (requestInfo != null)
{
WriteDirResponse(requestInfo.FilePath);
string staticContentType = GetStaticContentType(requestInfo);
if (!string.IsNullOrEmpty(staticContentType))
{
WriteFileResponse(requestInfo.FilePath, staticContentType);
}
else if (requestInfo.FilePath.EndsWith("/"))
{
WriteDirResponse(requestInfo.FilePath);
}
else
{
_host.ProcessRequest(this, requestInfo);
//WorkerRequest workerRequest = new WorkerRequest(this, requestInfo);
//HttpRuntime.ProcessRequest(workerRequest);
}
}
else
{
_host.ProcessRequest(this, requestInfo);
//WorkerRequest workerRequest = new WorkerRequest(this, requestInfo);
//HttpRuntime.ProcessRequest(workerRequest);
SendErrorResponse(400);
}
}
else
{
SendErrorResponse(400);
}
}
finally
{
Expand Down

0 comments on commit 48b170c

Please sign in to comment.