/** * creates a MultiPartBody by parsing a stream * * @param rawIn * @param boundary * the boundary-string delimiting the parts * @throws HandlerException */ public MultiPartBodyImpl(final InputStream rawIn, final String boundary) throws IOException { rawCollection = new ArrayList<KeyValuePair<ParameterValue>>(); DelimiterInputStream in = new DelimiterInputStream(rawIn); ByteArrayOutputStream delimiterBaos = new ByteArrayOutputStream(); delimiterBaos.write(45);// dash delimiterBaos.write(45); delimiterBaos.write(boundary.getBytes("utf-8")); byte[] delimiter = delimiterBaos.toByteArray(); in.readTill(delimiter); in.read(); // 13 in.read(); // 10 delimiterBaos = new ByteArrayOutputStream(); delimiterBaos.write(LINE_BREAK); delimiterBaos.write(delimiter); readFields(in, delimiterBaos.toByteArray()); // from rfc 2616: a bare CR // or LF MUST NOT be substituted for CRLF within any of the HTTP // control // structures (such as header fields and multipart boundaries) // this means we are strict in expecting CRLF }