Ejemplo n.º 1
0
        }                               //EF

        public SPDYResponseHeader(SPDYFrameSynReply synReplyFrame) : base(synReplyFrame as SPDYStreamFrame)
        {
            this.StatusCode = synReplyFrame.Fields[":status"];
        }
Ejemplo n.º 2
0
        protected SPDYFrameBase GetSPDYFrame()
        {
            var frameHeader = new Byte[8];

            if (this.Reader.Read(frameHeader, 0, frameHeader.Length) != frameHeader.Length)
            {
                this.Frames.AddRange(this.Reader.PDUStreamBasedProvider.GetCurrentPDU().FrameList);
                this.InvalidReason = "Not enough data for header";
                return(null);
            }

            var headerPdu    = this.Reader.PDUStreamBasedProvider.GetCurrentPDU();
            var headerFrames = headerPdu.FrameList;

            this.TimeStamp = headerPdu.FirstSeen;

            // First bit
            var isControl = (frameHeader[0] & 0x80) != 0;

            // Read payload
            // Payload len is in the last 3 bytes of 8 byte header
            var framePayloadLen       = SPDYFrameBase.ReadInt(frameHeader, 5, 3);
            var framePayload          = new Byte[framePayloadLen];
            var framePayloadReadBytes = this.Reader.Read(framePayload, 0, framePayloadLen);

            // Save frame numbers
            var payloadFrames = this.Reader.PDUStreamBasedProvider.GetCurrentPDU().FrameList;

            this.Frames.AddRange(headerFrames.Union(payloadFrames));

            if (framePayloadReadBytes != framePayloadLen)
            {
                this.InvalidReason = "Not enough data for payload";
                return(null);
            }

            SPDYFrameBase spdyFrame;

            if (isControl)
            {
                // Get control frame type
                var controlFrameType = (SPDYControlFrameType)(SPDYFrameBase.ReadInt(frameHeader, 2, 2));
                switch (controlFrameType)
                {
                case SPDYControlFrameType.SynStream:
                    spdyFrame = new SPDYFrameSynStream(frameHeader, framePayload);
                    break;

                case SPDYControlFrameType.SynReply:
                    spdyFrame = new SPDYFrameSynReply(frameHeader, framePayload);
                    break;

                case SPDYControlFrameType.Settings:
                    spdyFrame = new SPDYFrameSettings(frameHeader, framePayload);
                    break;

                case SPDYControlFrameType.WindowUpdate:
                    spdyFrame = new SPDYFrameWindowUpdate(frameHeader, framePayload);
                    break;

                case SPDYControlFrameType.Ping:
                    spdyFrame = new SPDYFramePing(frameHeader, framePayload);
                    break;

                default:
                    throw new Exception("Unsupported SPDY control frame type: " + controlFrameType);
                }
            }
            else
            {
                spdyFrame = new SPDYFrameData(frameHeader, framePayload);
            }

            // Copy of a list is needed, not just assign
            spdyFrame.Frames = new List <PmFrameBase>(this.Frames);

            return(spdyFrame);
        }