423695 - <HT> Horizontal-tab used as HTTP Header Field separator unsupported
Added tests to confirm that multivalue parsing is OK
This commit is contained in:
parent
dfe5889bc4
commit
084ed61711
|
@ -267,14 +267,45 @@ public class HttpFieldsTest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetValues() throws Exception
|
||||||
private Set<String> enum2set(Enumeration<String> e)
|
|
||||||
{
|
{
|
||||||
Set<String> s=new HashSet<String>();
|
HttpFields fields = new HttpFields();
|
||||||
while(e.hasMoreElements())
|
|
||||||
s.add(e.nextElement().toLowerCase(Locale.ENGLISH));
|
fields.put("name0", "value0A,value0B");
|
||||||
return s;
|
fields.add("name0", "value0C,value0D");
|
||||||
|
fields.put("name1", "value1A, \"value\t, 1B\" ");
|
||||||
|
fields.add("name1", "\"value1C\",\tvalue1D");
|
||||||
|
|
||||||
|
Enumeration<String> e = fields.getValues("name0");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value0A,value0B");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value0C,value0D");
|
||||||
|
assertEquals(false, e.hasMoreElements());
|
||||||
|
|
||||||
|
e = fields.getValues("name0",",");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value0A");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value0B");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value0C");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value0D");
|
||||||
|
assertEquals(false, e.hasMoreElements());
|
||||||
|
|
||||||
|
e = fields.getValues("name1",",");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value1A");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value\t, 1B");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value1C");
|
||||||
|
assertEquals(true, e.hasMoreElements());
|
||||||
|
assertEquals(e.nextElement(), "value1D");
|
||||||
|
assertEquals(false, e.hasMoreElements());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -338,6 +338,31 @@ public class HttpParserTest
|
||||||
assertEquals(9, _headers);
|
assertEquals(9, _headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testQuoted() throws Exception
|
||||||
|
{
|
||||||
|
ByteBuffer buffer= BufferUtil.toBuffer(
|
||||||
|
"GET / HTTP/1.0\n" +
|
||||||
|
"Name0: \"value0\"\t\n" +
|
||||||
|
"Name1: \"value\t1\"\n" +
|
||||||
|
"Name2: \"value\t2A\",\"value,2B\"\t\n" +
|
||||||
|
"\n");
|
||||||
|
HttpParser.RequestHandler<ByteBuffer> handler = new Handler();
|
||||||
|
HttpParser parser= new HttpParser(handler);
|
||||||
|
parseAll(parser,buffer);
|
||||||
|
|
||||||
|
assertEquals("GET", _methodOrVersion);
|
||||||
|
assertEquals("/", _uriOrStatus);
|
||||||
|
assertEquals("HTTP/1.0", _versionOrReason);
|
||||||
|
assertEquals("Name0", _hdr[0]);
|
||||||
|
assertEquals("\"value0\"", _val[0]);
|
||||||
|
assertEquals("Name1", _hdr[1]);
|
||||||
|
assertEquals("\"value\t1\"", _val[1]);
|
||||||
|
assertEquals("Name2", _hdr[2]);
|
||||||
|
assertEquals("\"value\t2A\",\"value,2B\"", _val[2]);
|
||||||
|
assertEquals(2, _headers);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodedHeader() throws Exception
|
public void testEncodedHeader() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue