Ejemplo n.º 1
0
        private static void SkipToFirstDelimiter(Stream inputStream, BinaryBufferWithPatternWatching buffer)
        {
            buffer.Start();

            while (true)
            {
                int value = inputStream.ReadByte();
                if (value == -1)
                {
                    throw ParserException("Unexpected end of stream (2).");
                }

                byte byteValue = (byte)value;
                if (buffer.WriteByte(byteValue))
                {
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        private static MultipartMessagePart ReadPart(
            MultipartMessage message,
            Stream inputStream,
            BinaryBufferWithPatternWatching buffer)
        {
            buffer.Start();

            while (true)
            {
                int value = inputStream.ReadByte();
                if (value == -1)
                {
                    throw ParserException("Unexpected end of stream (3).");
                }

                byte byteValue      = (byte)value;
                bool patternMatched = buffer.WriteByte(byteValue);

                if (!patternMatched)
                {
                    continue;
                }

                MultipartMessagePart part = ParsePart(
                    message,
                    buffer.ToArray(),
                    buffer.Pattern.Length);

                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Found part '{0}'", message.BaseEncoding.GetString(part.Data));
                }

                return(part);
            }
        }
Ejemplo n.º 3
0
        private static void SkipToFirstDelimiter(Stream inputStream, BinaryBufferWithPatternWatching buffer)
        {
            buffer.Start();

            while (true)
            {
                int value = inputStream.ReadByte();
                if (value == -1)
                    throw ParserException("Unexpected end of stream (2).");

                byte byteValue = (byte)value;
                if (buffer.WriteByte(byteValue))
                    return;
            }
        }
Ejemplo n.º 4
0
        private static MultipartMessagePart ReadPart(
            MultipartMessage message,
            Stream inputStream,
            BinaryBufferWithPatternWatching buffer)
        {
            buffer.Start();

            while (true)
            {
                int value = inputStream.ReadByte();
                if (value == -1)
                    throw ParserException("Unexpected end of stream (3).");

                byte byteValue = (byte)value;
                bool patternMatched = buffer.WriteByte(byteValue);

                if (!patternMatched)
                    continue;

                MultipartMessagePart part = ParsePart(
                    message,
                    buffer.ToArray(),
                    buffer.Pattern.Length);

                if (log.IsDebugEnabled)
                    log.DebugFormat("Found part '{0}'", message.BaseEncoding.GetString(part.Data));

                return part;
            }
        }