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) lock (this)
{ {
this.shutdown = true; this.shutdown = true;
}
foreach (TcpListener tcpListener in tcpListeners.Values) foreach (TcpListener tcpListener in tcpListeners.Values)
{ {
tcpListener.Stop(); tcpListener.Stop();
} }
threadPool.NumThreads = 0; threadPool.NumThreads = 0;
while (IsRunning) while (IsRunning)
{ {
Thread.Sleep(50); Thread.Sleep(50);
}
} }
} }

View File

@ -32,6 +32,21 @@ namespace ln.http
public Session Session { get; private set; } 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) public HttpRequest(HttpReader httpReader,IPEndPoint localEndpoint)
{ {
LocalEndpoint = localEndpoint; LocalEndpoint = localEndpoint;
@ -44,6 +59,19 @@ namespace ln.http
requestCookies = new Dictionary<string, string>(); requestCookies = new Dictionary<string, string>();
Setup(); 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() private void Setup()
@ -140,7 +168,10 @@ namespace ln.http
return requestCookies[name]; return requestCookies[name];
} }
public string self()
{
return BaseURI.ToString();
}