| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/spdy/hpack_encoder.h" | 5 #include "net/spdy/hpack_encoder.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 std::map<string, string> header_set; | 90 std::map<string, string> header_set; |
| 91 header_set["Cookie"] = "key1=value1; key2=value2"; | 91 header_set["Cookie"] = "key1=value1; key2=value2"; |
| 92 | 92 |
| 93 string encoded_header_set; | 93 string encoded_header_set; |
| 94 EXPECT_TRUE(encoder.EncodeHeaderSet(header_set, &encoded_header_set)); | 94 EXPECT_TRUE(encoder.EncodeHeaderSet(header_set, &encoded_header_set)); |
| 95 EXPECT_EQ("\x40\x06""Cookie\x0bkey1=value1" | 95 EXPECT_EQ("\x40\x06""Cookie\x0bkey1=value1" |
| 96 "\x40\x06""Cookie\x0bkey2=value2", encoded_header_set); | 96 "\x40\x06""Cookie\x0bkey2=value2", encoded_header_set); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Test that trying to encode a header set with a too-long header | |
| 100 // field will fail. | |
| 101 TEST(HpackEncoderTest, HeaderTooLarge) { | |
| 102 HpackEncoder encoder; | |
| 103 test::HpackEncoderPeer(&encoder).set_max_string_literal_size(10); | |
| 104 | |
| 105 std::map<string, string> header_set; | |
| 106 header_set["name1"] = "too-long value"; | |
| 107 header_set["name2"] = "value2"; | |
| 108 | |
| 109 // TODO(akalin): Verify that the encoder did not attempt to encode | |
| 110 // the second header field. | |
| 111 string encoded_header_set; | |
| 112 EXPECT_FALSE(encoder.EncodeHeaderSet(header_set, &encoded_header_set)); | |
| 113 } | |
| 114 | |
| 115 } // namespace | 99 } // namespace |
| 116 | 100 |
| 117 } // namespace net | 101 } // namespace net |
| OLD | NEW |