@Test public void testRawBodyParse() { ByteSequence buf = ContentUtil.encode( " text/plain ; charset=ISO-8859-1; " + "boundary=foo; param1=value1; param2=\"value2\"; param3=value3"); ParserCursor cursor = new ParserCursor(0, buf.length()); RawBody body = parser.parseRawBody(buf, cursor); org.junit.Assert.assertNotNull(body); org.junit.Assert.assertEquals("text/plain", body.getValue()); List<NameValuePair> params = body.getParams(); org.junit.Assert.assertEquals(5, params.size()); org.junit.Assert.assertEquals("charset", params.get(0).getName()); org.junit.Assert.assertEquals("ISO-8859-1", params.get(0).getValue()); org.junit.Assert.assertEquals("boundary", params.get(1).getName()); org.junit.Assert.assertEquals("foo", params.get(1).getValue()); org.junit.Assert.assertEquals("param1", params.get(2).getName()); org.junit.Assert.assertEquals("value1", params.get(2).getValue()); org.junit.Assert.assertEquals("param2", params.get(3).getName()); org.junit.Assert.assertEquals("value2", params.get(3).getValue()); org.junit.Assert.assertEquals("param3", params.get(4).getName()); org.junit.Assert.assertEquals("value3", params.get(4).getValue()); }
public RawBody parseRawBody(final RawField field) { ByteSequence buf = field.getRaw(); int pos = field.getDelimiterIdx() + 1; if (buf == null) { String body = field.getBody(); if (body == null) { return new RawBody("", null); } buf = ContentUtil.encode(body); pos = 0; } ParserCursor cursor = new ParserCursor(pos, buf.length()); return parseRawBody(buf, cursor); }
RawFieldParser { public RawBody parseRawBody(final RawField field) { ByteSequence buf = field.getRaw(); int pos = field.getDelimiterIdx() + 1; if (buf == null) { String body = field.getBody(); if (body == null) { return new RawBody("", null); } buf = ContentUtil.encode(body); pos = 0; } ParserCursor cursor = new ParserCursor(pos, buf.length()); return parseRawBody(buf, cursor); } }
RawFieldParser { public RawBody parseRawBody(final RawField field) { ByteSequence buf = field.getRaw(); int pos = field.getDelimiterIdx() + 1; if (buf == null) { String body = field.getBody(); if (body == null) { return new RawBody("", null); } buf = ContentUtil.encode(body); pos = 0; } ParserCursor cursor = new ParserCursor(pos, buf.length()); return parseRawBody(buf, cursor); }  }
RawFieldParser { public RawBody parseRawBody(final RawField field) { ByteSequence buf = field.getRaw(); int pos = field.getDelimiterIdx() + 1; if (buf == null) { String body = field.getBody(); if (body == null) { return new RawBody("", null); } buf = ContentUtil.encode(body); pos = 0; } ParserCursor cursor = new ParserCursor(pos, buf.length()); return parseRawBody(buf, cursor); }  static BitSet INIT_BITSET(int ... b); RawField parseField(final ByteSequence raw); RawBody parseRawBody(final RawField field); RawBody parseRawBody(final ByteSequence buf, final ParserCursor cursor); List<NameValuePair> parseParameters(final ByteSequence buf, final ParserCursor cursor); NameValuePair parseParameter(final ByteSequence buf, final ParserCursor cursor); String parseToken(final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters); String parseValue(final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters); void skipWhiteSpace(final ByteSequence buf, final ParserCursor cursor); void skipComment(final ByteSequence buf, final ParserCursor cursor); void skipAllWhiteSpace(final ByteSequence buf, final ParserCursor cursor); void copyContent(final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters,
            final StringBuilder dst); void copyUnquotedContent(final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters,
                            final StringBuilder dst); void copyQuotedContent(final ByteSequence buf, final ParserCursor cursor,
            final StringBuilder dst); }
RawFieldParser { public RawBody parseRawBody(final RawField field) { ByteSequence buf = field.getRaw(); int pos = field.getDelimiterIdx() + 1; if (buf == null) { String body = field.getBody(); if (body == null) { return new RawBody("", null); } buf = ContentUtil.encode(body); pos = 0; } ParserCursor cursor = new ParserCursor(pos, buf.length()); return parseRawBody(buf, cursor); }  static BitSet INIT_BITSET(int ... b); RawField parseField(final ByteSequence raw); RawBody parseRawBody(final RawField field); RawBody parseRawBody(final ByteSequence buf, final ParserCursor cursor); List<NameValuePair> parseParameters(final ByteSequence buf, final ParserCursor cursor); NameValuePair parseParameter(final ByteSequence buf, final ParserCursor cursor); String parseToken(final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters); String parseValue(final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters); void skipWhiteSpace(final ByteSequence buf, final ParserCursor cursor); void skipComment(final ByteSequence buf, final ParserCursor cursor); void skipAllWhiteSpace(final ByteSequence buf, final ParserCursor cursor); void copyContent(final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters,
            final StringBuilder dst); void copyUnquotedContent(final ByteSequence buf, final ParserCursor cursor, final BitSet delimiters,
                            final StringBuilder dst); void copyQuotedContent(final ByteSequence buf, final ParserCursor cursor,
            final StringBuilder dst); static final RawFieldParser DEFAULT; }