TestHeaders.cpp (1020B)
1 #include "gtest/gtest.h" 2 3 #include "nsHttpHeaderArray.h" 4 5 TEST(TestHeaders, DuplicateHSTS) 6 { 7 // When the Strict-Transport-Security header is sent multiple times, its 8 // effective value is the value of the first item. It is not merged as other 9 // headers are. 10 mozilla::net::nsHttpHeaderArray headers; 11 nsresult rv = headers.SetHeaderFromNet( 12 mozilla::net::nsHttp::Strict_Transport_Security, 13 "Strict_Transport_Security"_ns, "max-age=360"_ns, true); 14 ASSERT_EQ(rv, NS_OK); 15 16 nsAutoCString h; 17 rv = headers.GetHeader(mozilla::net::nsHttp::Strict_Transport_Security, h); 18 ASSERT_EQ(rv, NS_OK); 19 ASSERT_EQ(h.get(), "max-age=360"); 20 21 rv = headers.SetHeaderFromNet(mozilla::net::nsHttp::Strict_Transport_Security, 22 "Strict_Transport_Security"_ns, 23 "max-age=720"_ns, true); 24 ASSERT_EQ(rv, NS_OK); 25 26 rv = headers.GetHeader(mozilla::net::nsHttp::Strict_Transport_Security, h); 27 ASSERT_EQ(rv, NS_OK); 28 ASSERT_EQ(h.get(), "max-age=360"); 29 }