master
Harald Wolff 2019-03-14 08:35:54 +01:00
parent c4f456f8c5
commit 9aec7590b7
2 changed files with 41 additions and 10 deletions

View File

@ -81,18 +81,18 @@ namespace ln.http
lock (this)
{
this.shutdown = true;
}
foreach (TcpListener tcpListener in tcpListeners.Values)
{
tcpListener.Stop();
}
foreach (TcpListener tcpListener in tcpListeners.Values)
{
tcpListener.Stop();
}
threadPool.NumThreads = 0;
threadPool.NumThreads = 0;
while (IsRunning)
{
Thread.Sleep(50);
}
while (IsRunning)
{
Thread.Sleep(50);
}
}

View File

@ -32,6 +32,21 @@ namespace ln.http
public Session Session { get; private set; }
public MemoryStream ContentStream { get; }
public TextReader ContentReader
{
get
{
if (contentReader == null)
contentReader = new StreamReader(ContentStream);
return contentReader;
}
}
StreamReader contentReader;
byte[] requestBody;
public HttpRequest(HttpReader httpReader,IPEndPoint localEndpoint)
{
LocalEndpoint = localEndpoint;
@ -44,6 +59,19 @@ namespace ln.http
requestCookies = new Dictionary<string, string>();
Setup();
int clength = int.Parse(GetRequestHeader("content-length", "0"));
requestBody = new byte[clength];
if (clength > 0)
{
int nread = httpReader.ReadRequestBody(requestBody, 0, clength);
if (nread != clength)
throw new HttpException(500,"failed to read request content");
}
ContentStream = new MemoryStream(requestBody);
}
private void Setup()
@ -140,7 +168,10 @@ namespace ln.http
return requestCookies[name];
}
public string self()
{
return BaseURI.ToString();
}