private void ReadOne(Buffer buffer, LowLevelTcpConnection connection) { connection.ReadAsync(buffer.Segment.Array, buffer.Segment.Offset, buffer.Segment.Count, readBytes => { var readSegment = new ArraySegment <byte>(buffer.Segment.Array, 0, buffer.Segment.Offset + readBytes); int headersSize; var headers = TryParse(readSegment, out headersSize); if (headers != null) { FixBuffer(buffer.Segment.Array, headersSize, buffer.Segment.Offset + readBytes); StartHttp(headers, buffer.Segment.Array, connection); } else { ReadOne(new Buffer() { Segment = new ArraySegment <byte>(buffer.Segment.Array, buffer.Segment.Offset + readBytes, buffer.Segment.Count - readBytes), }, connection); } }); }
private void KeepAlive(byte[] buffer, LowLevelTcpConnection connection) { ReadOne(new Buffer() { Segment = new ArraySegment <byte>(buffer, 0, buffer.Length) }, connection); }
private void TcpProcess(IDaemon daemon, LowLevelTcpConnection connection) { Buffer buffer = new Buffer() { Segment = new ArraySegment <byte>(new byte[2048]) }; ReadOne(buffer, connection); }
private void StartHttp(string[] headers, byte[] buffer, LowLevelTcpConnection connection) { _daemonFactory.Spawn( (daemon) => { Logger.Debug("Staring http request processing :" + headers[0]); var startTime = DateTime.UtcNow; daemon.OnShutdown(() => { //connection.Process.Shutdown(); connection.Stream.Flush(); KeepAlive(buffer, connection); Logger.DebugFormat("Ending http request processing {0}", (DateTime.UtcNow - startTime).TotalMilliseconds); }); // todo add killer _httpProcessInitializer(daemon, HttpRequest.Create(headers), new HttpResponse(connection)); }); }
public HttpResponseStream(LowLevelTcpConnection connection) { _connection = connection; }
public HttpResponse(LowLevelTcpConnection connection) { _connection = connection; Stream = new HttpResponseStream(connection); }