예제 #1
0
        private void ParseRequest(Stream stream, DefaultLogger logger)
        {
            MemoryStream buffer = new MemoryStream();

            ReadToBuffer(stream, buffer);

            string startLine = ReadLine(stream, buffer);

            ParseStartLine(startLine);

            string headerLine = ReadLine(stream, buffer);

            while (headerLine != String.Empty)
            {
                ParseHeaderLine(headerLine);
                headerLine = ReadLine(stream, buffer);
            }

            ReadMessageBody(stream, buffer);
            if (Logging.TraceEnabled)
            {
                long position = buffer.Position;
                buffer.Position = 0;
                byte[]       bytes   = new byte[position];
                StreamReader reader  = new StreamReader(buffer);
                string       message = reader.ReadToEnd();
                if (message.Contains("\0"))
                {
                    message = message.Substring(0, message.IndexOf("\0"));
                }
                logger.TraceMessage(message);
                buffer.Position = position;
            }
        }