/** * <p> Constructor * * @param contentType The content type of the request * @param contentLength The content length of the request * @param charEncoding The request char encoding. */ public MultipartContext(final String contentType, final int contentLength, final String charEncoding) { if (!MultipartUtils.isMultipart(contentType)){ throw new IllegalStateException("Invalid content type '" + contentType + "'. Expected a multipart request"); } this.contentType = contentType; this.contentLength = contentLength; this.charEncoding = charEncoding; }
/** * <p> Constructor * * @param contentType The content type of the request * @param contentLength The content length of the request * @param charEncoding The request char encoding. */ public MultipartContext(final String contentType, final int contentLength, final String charEncoding) { if (!MultipartUtils.isMultipart(contentType)){ throw new IllegalStateException("Invalid content type '" + contentType + "'. Expected a multipart request"); } this.contentType = contentType; this.contentLength = contentLength; this.charEncoding = charEncoding; }
/** * <p> Checks if the headers contains a Content-Type header that defines a multipart request. * * @param headers The headers map * @return true if the request is a multipart request, false otherwise. */ public static boolean hasMultipartContentType(final Map<String, List<String>> headers){ return isMultipart(getContentType(headers)); }
/** * <p> Checks if the headers contains a Content-Type header that defines a multipart request. * * @param headers The headers map * @return true if the request is a multipart request, false otherwise. */ public static boolean hasMultipartContentType(final Map<String, List<String>> headers){ return isMultipart(getContentType(headers)); }
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(); }