コード例 #1
0
 public void Process(MultiPartHandler multiPartHandler)
 {
     this.Process(multiPartHandler, false);
 }
コード例 #2
0
        private void TryProcess(MultiPartHandler multiPartHandler, bool skipFirstCrNl)
        {
            DelimiterDetector detector = new DelimiterDetector(_boundary);

            if (skipFirstCrNl)
            {
                byte[] crnl = new byte[]{0x0d,0x0a}; // 0x0d = cr; 0x0a = nl
                detector.update(crnl, 0, 2);
            }

            DelimiterIndicator indicator = findFirstDelimiterIndicator(detector);

            if (null == indicator)
            {
                BaseException e = new BaseException(this, "null == indicator; expected delimiter at start of stream");
                throw e;
            }

            if (!(indicator is DelimiterFound))
            {
                log.error("unimplemented: support for `DelimiterIndicator` types that are not `DelimiterFound`");
                throw new BaseException(this, "!(indicator is DelimiterFound); indicator.GetType().Name", indicator.GetType().Name);
            }


            DelimiterFound delimiterFound = (DelimiterFound)indicator;

            _currentOffset = delimiterFound.EndOfDelimiter;


            while (!delimiterFound.IsCloseDelimiter)
            {
                delimiterFound = ProcessPart(multiPartHandler, detector);
            }

            multiPartHandler.FoundCloseDelimiter();

            while (0 != _contentRemaining)
            {
                FillBuffer();
            }

        }
コード例 #3
0
        public void Process( MultiPartHandler multiPartHandler, bool skipFirstCrNl ) 
        {

            try
            {
                TryProcess(multiPartHandler, skipFirstCrNl);                
            }
            catch (Exception e)
            {
                multiPartHandler.HandleException(e);
            }
        }
コード例 #4
0
        private DelimiterFound ProcessPart(MultiPartHandler multiPartHandler, DelimiterDetector detector)
        {

            PartHandler partHandler = multiPartHandler.FoundPartDelimiter();

            try
            {
                return TryProcessPart(partHandler, detector);
            }
            catch (Exception e)
            {
                partHandler.HandleException(e);
                throw e;
            }

        }