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

Unified Diff: net/spdy/hpack_encoder_test.cc

Issue 533073004: HPACK: Split header fields in encoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/spdy/hpack_encoder.cc ('k') | net/spdy/hpack_round_trip_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack_encoder_test.cc
diff --git a/net/spdy/hpack_encoder_test.cc b/net/spdy/hpack_encoder_test.cc
index 1667e0b4204c9f05243e8723db884865a52bdc07..af0e12a9ed25924a37b199e4b4a5d29265556169 100644
--- a/net/spdy/hpack_encoder_test.cc
+++ b/net/spdy/hpack_encoder_test.cc
@@ -70,6 +70,16 @@ class HpackEncoderPeer {
out->push_back(tmp[i].second);
}
}
+ static void DecomposeRepresentation(StringPiece value,
+ std::vector<StringPiece>* out) {
+ Representations tmp;
+ HpackEncoder::DecomposeRepresentation(make_pair("foobar", value), &tmp);
+
+ out->clear();
+ for (size_t i = 0; i != tmp.size(); ++i) {
+ out->push_back(tmp[i].second);
+ }
+ }
private:
HpackEncoder* encoder_;
@@ -413,6 +423,45 @@ TEST_F(HpackEncoderTest, UpdateCharacterCounts) {
EXPECT_EQ(9u, total_counts);
}
+TEST_F(HpackEncoderTest, DecomposeRepresentation) {
+ test::HpackEncoderPeer peer(NULL);
+ std::vector<StringPiece> out;
+
+ peer.DecomposeRepresentation("", &out);
+ EXPECT_THAT(out, ElementsAre(""));
+
+ peer.DecomposeRepresentation("foobar", &out);
+ EXPECT_THAT(out, ElementsAre("foobar"));
+
+ peer.DecomposeRepresentation(StringPiece("foo\0bar", 7), &out);
+ EXPECT_THAT(out, ElementsAre("foo", "bar"));
+
+ peer.DecomposeRepresentation(StringPiece("\0foo\0bar", 8), &out);
+ EXPECT_THAT(out, ElementsAre("", "foo", "bar"));
+
+ peer.DecomposeRepresentation(StringPiece("foo\0bar\0", 8), &out);
+ EXPECT_THAT(out, ElementsAre("foo", "bar", ""));
+
+ peer.DecomposeRepresentation(StringPiece("\0foo\0bar\0", 9), &out);
+ EXPECT_THAT(out, ElementsAre("", "foo", "bar", ""));
+}
+
+// Test that encoded headers do not have \0-delimited multiple values, as this
+// became disallowed in HTTP/2 draft-14.
+TEST_F(HpackEncoderTest, CrumbleNullByteDelimitedValue) {
+ map<string, string> headers;
+ // A header field to be crumbled: "spam: foo\0bar".
+ headers["spam"] = string("foo\0bar", 7);
+
+ ExpectIndexedLiteral("spam", "foo");
+ expected_.AppendPrefix(kLiteralIncrementalIndexOpcode);
+ expected_.AppendUint32(62);
+ expected_.AppendPrefix(kStringLiteralIdentityEncoded);
+ expected_.AppendUint32(3);
+ expected_.AppendBytes("bar");
+ CompareWithExpectedEncoding(headers);
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/spdy/hpack_encoder.cc ('k') | net/spdy/hpack_round_trip_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698