@Test public void testHEFringeCase2() throws Exception { final String headerValue = "name1 = value1, "; final CharArrayBuffer buf = new CharArrayBuffer(64); buf.append(headerValue); final ParserCursor cursor = new ParserCursor(0, buf.length()); final HeaderElement[] elements = this.parser.parseElements(buf, cursor); Assert.assertEquals("Number of elements", 1, elements.length); }
@Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.size()]); }
BasicHeaderValueParser implements HeaderValueParser { @Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.size()]); } }
BasicHeaderValueParser implements HeaderValueParser { @Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.size()]); } BasicHeaderValueParser(); }
BasicHeaderValueParser implements HeaderValueParser { @Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.size()]); } BasicHeaderValueParser(); @Override HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor); @Override HeaderElement parseHeaderElement(final CharSequence buffer, final ParserCursor cursor); @Override NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor); @Override NameValuePair parseNameValuePair(final CharSequence buffer, final ParserCursor cursor); }
BasicHeaderValueParser implements HeaderValueParser { @Override public HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor) { Args.notNull(buffer, "Char sequence"); Args.notNull(cursor, "Parser cursor"); final List<HeaderElement> elements = new ArrayList<>(); while (!cursor.atEnd()) { final HeaderElement element = parseHeaderElement(buffer, cursor); if (!(element.getName().isEmpty() && element.getValue() == null)) { elements.add(element); } } return elements.toArray(new HeaderElement[elements.size()]); } BasicHeaderValueParser(); @Override HeaderElement[] parseElements(final CharSequence buffer, final ParserCursor cursor); @Override HeaderElement parseHeaderElement(final CharSequence buffer, final ParserCursor cursor); @Override NameValuePair[] parseParameters(final CharSequence buffer, final ParserCursor cursor); @Override NameValuePair parseNameValuePair(final CharSequence buffer, final ParserCursor cursor); final static BasicHeaderValueParser INSTANCE; }