コード例 #1
0
 public Connection(TcpSocket socket, HeadParser <Incoming> headParser, HeadSerializer <Outgoing> headSerializer,
                   HttpMessageHandler <Incoming, Outgoing> messageHandler)
 {
     Base           = socket;
     HeadParser     = headParser;
     HeadSerializer = headSerializer;
     BodyParser     = new BodyParser();
     BodySerializer = new BodySerializer();
     OnMessage      = messageHandler;
     new Thread(ProcessorThread)
     {
         Name = "HTTP pipeline thread"
     }.Start();
     Base.OnClose += End;
 }
コード例 #2
0
 virtual protected void End()
 {
     HeadParser.Unpipe();
     BodyParser.Unpipe();
     if (!Base.ReadableEnded && !Upgrading)
     {
         Base.Unpipe();
     }
     HeadSerializer.Unpipe();
     BodySerializer.Unpipe();
     HeadParser.End();
     HeadSerializer.End();
     BodyParser.End();
     BodySerializer.End();
     OnEnd?.Invoke();
 }
コード例 #3
0
        virtual public byte[] SetUpgrading()
        {
            Upgrading     = true;
            Base.OnClose -= End;
            byte[] trail = new byte[HeadParser.Buffered + BodyParser.OutgoingBuffered];
            int    index = 0;

            if (HeadParser.Buffered > 0)
            {
                byte[] trail1 = HeadParser.Read();
                Buffer.BlockCopy(trail1, 0, trail, index, trail1.Length);
                index += trail1.Length;
            }
            if (HeadParser.Buffered > 0)
            {
                byte[] trail2 = HeadParser.Read();
                Buffer.BlockCopy(trail2, 0, trail, index, trail2.Length);
            }
            return(trail);
        }