Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] org.eclipse.jetty.http.HttpField


So wrote this test code:
public void testEtag()
{
HttpFields fields = new HttpFields();
fields.add("ETag", "W/\"11111\",W/22222");
fields.add("ETag", "W/\"33333\"");

System.err.println("Collections.list(fields.getValues(\"Etag\"))");
Collections.list(fields.getValues("Etag")).forEach(System.err::println);
System.err.println("Collections.list(fields.getValues(\"Etag\", \",\"))");
Collections.list(fields.getValues("Etag", ",")).forEach(System.err::println);
System.err.println("fields.getCSV(\"Etag\", false)");
fields.getCSV("Etag", false).forEach(System.err::println);
System.err.println("fields.getCSV(\"Etag\", true)");
fields.getCSV("Etag", true).forEach(System.err::println);
}
which cage the output:

Collections.list(fields.getValues("Etag"))
W/"11111",W/22222
W/"33333"
Collections.list(fields.getValues("Etag", ","))
W/11111
W/22222
W/33333
fields.getCSV("Etag", false)
W/11111
W/22222
W/33333
fields.getCSV("Etag", true)
W/"11111"
W/22222
W/"33333"

So fields.getCSV("Etag", true) is the method you want.  
Note also that fields.getValues("Etag", ",") is deprecated!

-- 

Back to the top