示例#1
0
        private HTTPMessage ParseNode(TransactionNode httpNode, bool isRequest)
        {
            IPPacket pkt = httpNode.Slices[0].Packet;

            HTTPMessage msg = new HTTPMessage(httpNode.Index, pkt.Direction, pkt.Timestamp);

            if (isRequest)
            {
                msg.HeadlineText = String.Format("{0} {1} {2}", httpNode["Verb"], httpNode["Argument"], httpNode["Protocol"]);
            }
            else
            {
                msg.HeadlineText = String.Format("{0} {1}", httpNode["Protocol"], httpNode["Result"]);
            }

            TransactionNode headersNode = httpNode.FindChild("Headers", false);

            if (headersNode != null)
            {
                foreach (string name in headersNode.FieldNames)
                {
                    msg.AddHeaderField(name, headersNode.Fields[name]);
                }
            }

            TransactionNode bodyNode = httpNode.FindChild("Body", false);

            if (bodyNode != null)
            {
                if (bodyNode.Fields.ContainsKey("XML"))
                {
                    string         body;
                    XmlHighlighter highlighter = new XmlHighlighter(XmlHighlightColorScheme.VisualizationScheme);

                    XmlUtils.PrettyPrint((string)bodyNode["XML"], out body, highlighter);

                    msg.BodyText = body;

                    highlighter.HighlightRichTextBox(msg.BodyBox);
                }
                else if (bodyNode.Fields.ContainsKey("HTML"))
                {
                    msg.BodyText = (string)bodyNode["HTML"];
                }
                else if (bodyNode.Fields.ContainsKey("Raw"))
                {
                    msg.SetBodyFromPreviewData((byte[])bodyNode.Fields["Raw"], 512);
                }
                else
                {
                    msg.BodyText = String.Format("{0} unhandled", bodyNode.FieldNames[0]);
                }
            }

            return(msg);
        }
示例#2
0
文件: HTTP.cs 项目: SayHalou/ospy
        private HTTPMessage ParseNode(TransactionNode httpNode, bool isRequest)
        {
            IPPacket pkt = httpNode.Slices[0].Packet;

            HTTPMessage msg = new HTTPMessage(httpNode.Index, pkt.Direction, pkt.Timestamp);

            if (isRequest)
            {
                msg.HeadlineText = String.Format("{0} {1} {2}", httpNode["Verb"], httpNode["Argument"], httpNode["Protocol"]);
            }
            else
            {
                msg.HeadlineText = String.Format("{0} {1}", httpNode["Protocol"], httpNode["Result"]);
            }

            TransactionNode headersNode = httpNode.FindChild("Headers", false);
            if (headersNode != null)
            {
                foreach (string name in headersNode.FieldNames)
                {
                    msg.AddHeaderField(name, headersNode.Fields[name]);
                }
            }

            TransactionNode bodyNode = httpNode.FindChild("Body", false);
            if (bodyNode != null)
            {
                if (bodyNode.Fields.ContainsKey("XML"))
                {
                    string body;
                    XmlHighlighter highlighter = new XmlHighlighter(XmlHighlightColorScheme.VisualizationScheme);

                    XmlUtils.PrettyPrint((string)bodyNode["XML"], out body, highlighter);

                    msg.BodyText = body;

                    highlighter.HighlightRichTextBox(msg.BodyBox);
                }
                else if (bodyNode.Fields.ContainsKey("HTML"))
                {
                    msg.BodyText = (string)bodyNode["HTML"];
                }
                else if (bodyNode.Fields.ContainsKey("Raw"))
                {
                    msg.SetBodyFromPreviewData((byte[])bodyNode.Fields["Raw"], 512);
                }
                else
                {
                    msg.BodyText = String.Format("{0} unhandled", bodyNode.FieldNames[0]);
                }
            }

            return msg;
        }