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

Unified Diff: net/quic/spdy_utils_test.cc

Issue 2086533002: Fix a bug in QUIC's SpdyUtils where Content-Length was being parsed as an int, not an int64, causin… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/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/spdy_utils_test.cc
diff --git a/net/quic/spdy_utils_test.cc b/net/quic/spdy_utils_test.cc
index 12e66692c43d669767f2fa45db531bc7b3836a3f..55ec43c837b8a62da5175eeb0a1ec223d54d1cea 100644
--- a/net/quic/spdy_utils_test.cc
+++ b/net/quic/spdy_utils_test.cc
@@ -25,8 +25,37 @@ TEST(SpdyUtilsTest, SerializeAndParseHeaders) {
input_headers[":pseudo1"] = "pseudo value1";
input_headers[":pseudo2"] = "pseudo value2";
input_headers["key1"] = "value1";
- const int kContentLength = 1234;
- input_headers["content-length"] = base::IntToString(kContentLength);
+ const int64_t kContentLength = 1234;
+ input_headers["content-length"] = base::Int64ToString(kContentLength);
+ input_headers["key2"] = "value2";
+
+ // Serialize the header block.
+ string serialized_headers =
+ SpdyUtils::SerializeUncompressedHeaders(input_headers);
+
+ // Take the serialized header block, and parse back into SpdyHeaderBlock.
+ SpdyHeaderBlock output_headers;
+ int64_t content_length = -1;
+ ASSERT_TRUE(SpdyUtils::ParseHeaders(serialized_headers.data(),
+ serialized_headers.size(),
+ &content_length, &output_headers));
+
+ // Should be back to the original headers.
+ EXPECT_EQ(content_length, kContentLength);
+ EXPECT_EQ(output_headers, input_headers);
+}
+
+TEST(SpdyUtilsTest, SerializeAndParseHeadersLargeContentLength) {
+ // Creates a SpdyHeaderBlock with some key->value pairs, serializes it, then
+ // parses the serialized output and verifies that the end result is the same
+ // as the headers that the test started with.
+
+ SpdyHeaderBlock input_headers;
+ input_headers[":pseudo1"] = "pseudo value1";
+ input_headers[":pseudo2"] = "pseudo value2";
+ input_headers["key1"] = "value1";
+ const int64_t kContentLength = 12345678900;
+ input_headers["content-length"] = base::Int64ToString(kContentLength);
input_headers["key2"] = "value2";
// Serialize the header block.
« no previous file with comments | « net/quic/spdy_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698