public void Process(MultiPartHandler multiPartHandler) { this.Process(multiPartHandler, false); }
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(); } }
public void Process( MultiPartHandler multiPartHandler, bool skipFirstCrNl ) { try { TryProcess(multiPartHandler, skipFirstCrNl); } catch (Exception e) { multiPartHandler.HandleException(e); } }
private DelimiterFound ProcessPart(MultiPartHandler multiPartHandler, DelimiterDetector detector) { PartHandler partHandler = multiPartHandler.FoundPartDelimiter(); try { return TryProcessPart(partHandler, detector); } catch (Exception e) { partHandler.HandleException(e); throw e; } }