Пример #1
0
 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);
         }
     });
 }
Пример #2
0
 private void KeepAlive(byte[] buffer, LowLevelTcpConnection connection)
 {
     ReadOne(new Buffer()
     {
         Segment = new ArraySegment <byte>(buffer, 0, buffer.Length)
     }, connection);
 }
Пример #3
0
        private void TcpProcess(IDaemon daemon, LowLevelTcpConnection connection)
        {
            Buffer buffer =
                new Buffer()
            {
                Segment = new ArraySegment <byte>(new byte[2048])
            };

            ReadOne(buffer, connection);
        }
Пример #4
0
 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));
     });
 }
Пример #5
0
 public HttpResponseStream(LowLevelTcpConnection connection)
 {
     _connection = connection;
 }
Пример #6
0
 public HttpResponse(LowLevelTcpConnection connection)
 {
     _connection = connection;
     Stream      = new HttpResponseStream(connection);
 }