Prepare make ThreadPool of HTTPServer public available

master
Harald Wolff 2019-10-18 12:31:41 +02:00
parent 89f748cea4
commit 89dddbc07b
4 changed files with 9 additions and 4 deletions

View File

@ -39,6 +39,7 @@ namespace ln.http
Dictionary<TcpListener, Thread> currentListenerThreads = new Dictionary<TcpListener, Thread>(); Dictionary<TcpListener, Thread> currentListenerThreads = new Dictionary<TcpListener, Thread>();
DynamicPool threadPool; DynamicPool threadPool;
public DynamicPool ThreadPool => threadPool;
public HTTPServer() public HTTPServer()
{ {

View File

@ -64,7 +64,7 @@ namespace ln.http
HttpResponse response = null; HttpResponse response = null;
using (CurrentRequest = new HttpRequest(httpReader, (IPEndPoint)TcpClient.Client.LocalEndPoint)) using (CurrentRequest = new HttpRequest(this.HTTPServer,httpReader, (IPEndPoint)TcpClient.Client.LocalEndPoint))
{ {
CurrentRequest.ApplySession(HTTPServer.SessionCache); CurrentRequest.ApplySession(HTTPServer.SessionCache);

View File

@ -15,7 +15,9 @@ namespace ln.http
Dictionary<String, String> requestHeaders; Dictionary<String, String> requestHeaders;
Dictionary<String, String> requestCookies; Dictionary<String, String> requestCookies;
public IPEndPoint RemoteEndpoint { get; private set; } public HTTPServer HTTPServer { get; }
public IPEndPoint RemoteEndpoint { get; private set; }
public IPEndPoint LocalEndpoint { get; private set; } public IPEndPoint LocalEndpoint { get; private set; }
public Uri BaseURI { get; set; } public Uri BaseURI { get; set; }
@ -52,8 +54,9 @@ namespace ln.http
byte[] requestBody; byte[] requestBody;
Stream connectionStream; Stream connectionStream;
public HttpRequest(HttpReader httpReader,IPEndPoint localEndpoint) public HttpRequest(HTTPServer httpServer, HttpReader httpReader, IPEndPoint localEndpoint)
{ {
HTTPServer = httpServer;
connectionStream = httpReader.Stream; connectionStream = httpReader.Stream;
LocalEndpoint = localEndpoint; LocalEndpoint = localEndpoint;
@ -75,7 +78,7 @@ namespace ln.http
{ {
int nread = httpReader.ReadRequestBody(requestBody, 0, clength); int nread = httpReader.ReadRequestBody(requestBody, 0, clength);
if (nread != clength) if (nread != clength)
throw new HttpException(500,"failed to read request content"); throw new HttpException(500, "failed to read request content");
} }
ContentStream = new MemoryStream(requestBody); ContentStream = new MemoryStream(requestBody);

View File

@ -34,6 +34,7 @@ namespace ln.http.websocket
public class WebSocket public class WebSocket
{ {
public HTTPServer HTTPServer => HttpRequest.HTTPServer;
public HttpRequest HttpRequest { get; } public HttpRequest HttpRequest { get; }
public Stream Stream { get; } public Stream Stream { get; }