use of org.apache.hc.core5.util.CharArrayBuffer in project httpcomponents-core by apache.
the class TestMessageSupport method testParseTokenBufferedHeader.
@Test
public void testParseTokenBufferedHeader() throws Exception {
final CharArrayBuffer buf = new CharArrayBuffer(128);
buf.append("stuff: a, b, c, c");
final Header header = BufferedHeader.create(buf);
Assertions.assertEquals(makeSet("a", "b", "c"), MessageSupport.parseTokens(header));
}
use of org.apache.hc.core5.util.CharArrayBuffer in project httpcomponents-core by apache.
the class TestBasicHeaderValueFormatter method testHEFormatting.
@Test
public void testHEFormatting() throws Exception {
final NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff");
final NameValuePair param2 = new BasicNameValuePair("param", "this\\that");
final NameValuePair param3 = new BasicNameValuePair("param", "this,that");
final NameValuePair param4 = new BasicNameValuePair("param", null);
final NameValuePair[] params = new NameValuePair[] { param1, param2, param3, param4 };
final HeaderElement element = new BasicHeaderElement("name", "value", params);
final CharArrayBuffer buf = new CharArrayBuffer(64);
this.formatter.formatHeaderElement(buf, element, false);
Assertions.assertEquals("name=value; param=regular_stuff; param=\"this\\\\that\"; param=\"this,that\"; param", buf.toString());
}
use of org.apache.hc.core5.util.CharArrayBuffer in project httpcomponents-core by apache.
the class TestBasicHeaderValueParser method testHEFringeCase1.
@Test
public void testHEFringeCase1() 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);
Assertions.assertEquals(1, elements.length, "Number of elements");
}
use of org.apache.hc.core5.util.CharArrayBuffer in project httpcomponents-core by apache.
the class TestBasicHeaderValueParser method testHEFringeCase3.
@Test
public void testHEFringeCase3() throws Exception {
final String headerValue = ",, ,, ,";
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);
Assertions.assertEquals(0, elements.length, "Number of elements");
}
use of org.apache.hc.core5.util.CharArrayBuffer in project httpcomponents-core by apache.
the class TestBasicHeaderValueParser method testHEFringeCase2.
@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);
Assertions.assertEquals(1, elements.length, "Number of elements");
}
Aggregations