void identifyDelimiter(final WriteContext wCtx, final State onDelimiter, final State onCloseDelimiter) { int byteOfData; while ((byteOfData = wCtx.read()) != -1) { delimiterType.addDelimiterByte((byte)byteOfData); if (delimiterType.index >= 2) { DelimiterType.Type type = delimiterType.getDelimiterType(); if (DelimiterType.Type.ENCAPSULATION == type) { goToState(onDelimiter); wCtx.setFinishedIfNoMoreData(); return; } else if (DelimiterType.Type.CLOSE == type) { goToState(onCloseDelimiter); // Need to continue because we encountered a close delimiter and we might not have more data coming // but we want to switch state and notify. wCtx.setNotFinished(); return; } else { goToState(State.ERROR); nioMultipartParserListener.onError("Unexpected characters follow a boundary", null); wCtx.setFinished(); return; } } } wCtx.setFinishedIfNoMoreData(); }
void identifyDelimiter(final WriteContext wCtx, final State onDelimiter, final State onCloseDelimiter) { int byteOfData; while ((byteOfData = wCtx.read()) != -1) { delimiterType.addDelimiterByte((byte)byteOfData); if (delimiterType.index >= 2) { DelimiterType.Type type = delimiterType.getDelimiterType(); if (DelimiterType.Type.ENCAPSULATION == type) { goToState(onDelimiter); wCtx.setFinishedIfNoMoreData(); return; } else if (DelimiterType.Type.CLOSE == type) { goToState(onCloseDelimiter); // Need to continue because we encountered a close delimiter and we might not have more data coming // but we want to switch state and notify. wCtx.setNotFinished(); return; } else { goToState(State.ERROR); nioMultipartParserListener.onError("Unexpected characters follow a boundary", null); wCtx.setFinished(); return; } } } wCtx.setFinishedIfNoMoreData(); }
void readHeaders(final WriteContext wCtx) { int byteOfData; while ((byteOfData = wCtx.read()) != -1) { if (endOfLineBuffer.write((byte)byteOfData)) { parseHeaders(); String contentType = MultipartUtils.getHeader(MultipartUtils.CONTENT_TYPE, headers); if (MultipartUtils.isMultipart(contentType)) { goToState(State.GET_READY_FOR_NESTED_MULTIPART); } else { goToState(State.GET_READY_FOR_BODY); } wCtx.setFinishedIfNoMoreData(); return; } } wCtx.setFinishedIfNoMoreData(); }
void readHeaders(final WriteContext wCtx) { int byteOfData; while ((byteOfData = wCtx.read()) != -1) { if (endOfLineBuffer.write((byte)byteOfData)) { parseHeaders(); String contentType = MultipartUtils.getHeader(MultipartUtils.CONTENT_TYPE, headers); if (MultipartUtils.isMultipart(contentType)) { goToState(State.GET_READY_FOR_NESTED_MULTIPART); } else { goToState(State.GET_READY_FOR_BODY); } wCtx.setFinishedIfNoMoreData(); return; } } wCtx.setFinishedIfNoMoreData(); }
void readBody(final WriteContext wCtx) { int byteOfData; while ((byteOfData = wCtx.read()) != -1) { if (endOfLineBuffer.write((byte)byteOfData)) { goToState(State.IDENTIFY_BODY_DELIMITER); wCtx.setFinishedIfNoMoreData(); return; } } wCtx.setFinishedIfNoMoreData(); }
void readBody(final WriteContext wCtx) { int byteOfData; while ((byteOfData = wCtx.read()) != -1) { if (endOfLineBuffer.write((byte)byteOfData)) { goToState(State.IDENTIFY_BODY_DELIMITER); wCtx.setFinishedIfNoMoreData(); return; } } wCtx.setFinishedIfNoMoreData(); }
void skipPreamble(final WriteContext wCtx) { int byteOfData; while ((byteOfData = wCtx.read()) != -1) { if (endOfLineBuffer.write((byte)byteOfData)) { goToState(State.IDENTIFY_PREAMBLE_DELIMITER); wCtx.setFinishedIfNoMoreData(); return; } } wCtx.setFinishedIfNoMoreData(); }
void skipPreamble(final WriteContext wCtx) { int byteOfData; while ((byteOfData = wCtx.read()) != -1) { if (endOfLineBuffer.write((byte)byteOfData)) { goToState(State.IDENTIFY_PREAMBLE_DELIMITER); wCtx.setFinishedIfNoMoreData(); return; } } wCtx.setFinishedIfNoMoreData(); }