ok2c commented on code in PR #868:
URL:
https://github.com/apache/httpcomponents-client/pull/868#discussion_r3791782561
##########
httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlParserTest.java:
##########
@@ -207,6 +207,46 @@ void testParseNoCacheFieldsMessy() {
assertEquals(120, cacheControl.getStaleWhileRevalidate());
}
+ @Test
+ void testParsePrivateFields() {
+ final Header header = new BasicHeader("Cache-Control",
"private=\"X-Private, X-Secret\", s-maxage=3600");
+ final ResponseCacheControl cacheControl =
parser.parseResponse(Collections.singletonList(header).iterator());
+
+ assertTrue(cacheControl.isCachePrivate());
+ assertEquals(2, cacheControl.getPrivateFields().size());
+ assertTrue(cacheControl.getPrivateFields().contains("X-Private"));
+ assertTrue(cacheControl.getPrivateFields().contains("X-Secret"));
+ }
+
+ @Test
+ void testParseBarePrivateHasNoFields() {
+ final Header header = new BasicHeader("Cache-Control", "private,
s-maxage=3600");
+ final ResponseCacheControl cacheControl =
parser.parseResponse(Collections.singletonList(header).iterator());
+
+ assertTrue(cacheControl.isCachePrivate());
+ assertTrue(cacheControl.getPrivateFields().isEmpty());
+ }
+
+ @Test
+ void testParseMultiplePrivateDirectivesAccumulate() {
+ final Header header = new BasicHeader("Cache-Control",
"private=\"X-A\", private=\"X-B\", s-maxage=3600");
Review Comment:
@arturobernalg What part of the spec actually defines or recommends such
behavior? In my opinion only `private=\"X-B\"` should have an effect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]