Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Unified Diff: net/quic/core/spdy_utils_test.cc

Issue 2963863002: Allow trailing headers with duplicate keys. Protected by FLAGS_quic_reloadable_flag_quic_allow_dupl… (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/spdy_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/spdy_utils_test.cc
diff --git a/net/quic/core/spdy_utils_test.cc b/net/quic/core/spdy_utils_test.cc
index b5978aa74c44425a85ce56b979bc129b4dbdc39d..6acfc83d01b987b2bbcc754e916ac399f2e01046 100644
--- a/net/quic/core/spdy_utils_test.cc
+++ b/net/quic/core/spdy_utils_test.cc
@@ -6,6 +6,8 @@
#include <memory>
#include "base/macros.h"
+#include "net/quic/platform/api/quic_flag_utils.h"
+#include "net/quic/platform/api/quic_flags.h"
#include "net/quic/platform/api/quic_string_piece.h"
#include "net/quic/platform/api/quic_text_utils.h"
#include "net/test/gtest_util.h"
@@ -246,7 +248,10 @@ TEST(CopyAndValidateTrailers, PseudoHeaderInTrailers) {
}
TEST(CopyAndValidateTrailers, DuplicateTrailers) {
- // Duplicate trailers are not allowed.
+ // Duplicate trailers are allowed, and their values are concatenated into a
+ // single string delimted with '\0'. Some of the duplicate headers
+ // deliberately have an empty value.
+ FLAGS_quic_reloadable_flag_quic_handle_duplicate_trailers = true;
auto trailers = FromList({{"key", "value0"},
{"key", "value1"},
{"key", ""},
@@ -258,8 +263,38 @@ TEST(CopyAndValidateTrailers, DuplicateTrailers) {
{"key", "non_contiguous_duplicate"}});
size_t final_byte_offset = 0;
SpdyHeaderBlock block;
- EXPECT_FALSE(SpdyUtils::CopyAndValidateTrailers(*trailers, &final_byte_offset,
- &block));
+ EXPECT_TRUE(SpdyUtils::CopyAndValidateTrailers(*trailers, &final_byte_offset,
+ &block));
+ EXPECT_THAT(
+ block,
+ UnorderedElementsAre(
+ Pair("key",
+ QuicStringPiece(
+ "value0\0value1\0\0\0value2\0\0non_contiguous_duplicate",
+ 48)),
+ Pair("other_key", "value")));
+}
+
+TEST(CopyAndValidateTrailers, DuplicateCookies) {
+ // Duplicate cookie headers in trailers should be concatenated into a single
+ // "; " delimted string.
+ FLAGS_quic_reloadable_flag_quic_handle_duplicate_trailers = true;
+ auto headers = FromList({{"cookie", " part 1"},
+ {"cookie", "part 2 "},
+ {"cookie", "part3"},
+ {"key", "value"},
+ {kFinalOffsetHeaderKey, "1234"},
+ {"cookie", " non_contiguous_cookie!"}});
+
+ size_t final_byte_offset = 0;
+ SpdyHeaderBlock block;
+ EXPECT_TRUE(
+ SpdyUtils::CopyAndValidateTrailers(*headers, &final_byte_offset, &block));
+ EXPECT_THAT(
+ block,
+ UnorderedElementsAre(
+ Pair("cookie", " part 1; part 2 ; part3; non_contiguous_cookie!"),
+ Pair("key", "value")));
}
TEST(GetUrlFromHeaderBlock, Basic) {
« no previous file with comments | « net/quic/core/spdy_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698