OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/spdy_test_utils.h" | 5 #include "net/spdy/spdy_test_utils.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 << "\n\nExpected:\n" | 85 << "\n\nExpected:\n" |
86 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len) | 86 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len) |
87 << "\nActual:\n" | 87 << "\nActual:\n" |
88 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); | 88 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); |
89 } | 89 } |
90 | 90 |
91 void SetFrameFlags(SpdyFrame* frame, | 91 void SetFrameFlags(SpdyFrame* frame, |
92 uint8_t flags, | 92 uint8_t flags, |
93 SpdyMajorVersion spdy_version) { | 93 SpdyMajorVersion spdy_version) { |
94 switch (spdy_version) { | 94 switch (spdy_version) { |
95 case SPDY2: | |
96 case SPDY3: | 95 case SPDY3: |
97 case HTTP2: | 96 case HTTP2: |
98 frame->data()[4] = flags; | 97 frame->data()[4] = flags; |
99 break; | 98 break; |
100 default: | 99 default: |
101 LOG(FATAL) << "Unsupported SPDY version."; | 100 LOG(FATAL) << "Unsupported SPDY version."; |
102 } | 101 } |
103 } | 102 } |
104 | 103 |
105 void SetFrameLength(SpdyFrame* frame, | 104 void SetFrameLength(SpdyFrame* frame, |
106 size_t length, | 105 size_t length, |
107 SpdyMajorVersion spdy_version) { | 106 SpdyMajorVersion spdy_version) { |
108 switch (spdy_version) { | 107 switch (spdy_version) { |
109 case SPDY2: | |
110 case SPDY3: | 108 case SPDY3: |
111 CHECK_EQ(0u, length & ~kLengthMask); | 109 CHECK_EQ(0u, length & ~kLengthMask); |
112 { | 110 { |
113 int32_t wire_length = base::HostToNet32(length); | 111 int32_t wire_length = base::HostToNet32(length); |
114 // The length field in SPDY 2 and 3 is a 24-bit (3B) integer starting at | 112 // The length field in SPDY 2 is a 24-bit (3B) integer starting at |
Ryan Hamilton
2016/01/07 22:09:15
s/2/3/ ?
Bence
2016/01/08 18:58:25
Oops.
| |
115 // offset 5. | 113 // offset 5. |
116 memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3); | 114 memcpy(frame->data() + 5, reinterpret_cast<char*>(&wire_length) + 1, 3); |
117 } | 115 } |
118 break; | 116 break; |
119 case HTTP2: | 117 case HTTP2: |
120 CHECK_GT(1u<<14, length); | 118 CHECK_GT(1u<<14, length); |
121 { | 119 { |
122 int32_t wire_length = base::HostToNet32(length); | 120 int32_t wire_length = base::HostToNet32(length); |
123 memcpy(frame->data(), | 121 memcpy(frame->data(), |
124 reinterpret_cast<char*>(&wire_length) + 1, | 122 reinterpret_cast<char*>(&wire_length) + 1, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 | 161 |
164 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. | 162 // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. |
165 SSLInfo ssl_info; | 163 SSLInfo ssl_info; |
166 ssl_info.is_issued_by_known_root = true; | 164 ssl_info.is_issued_by_known_root = true; |
167 ssl_info.public_key_hashes.push_back(GetTestHashValue(primary_label)); | 165 ssl_info.public_key_hashes.push_back(GetTestHashValue(primary_label)); |
168 EXPECT_TRUE(state->AddHPKPHeader(host, header, ssl_info)); | 166 EXPECT_TRUE(state->AddHPKPHeader(host, header, ssl_info)); |
169 } | 167 } |
170 | 168 |
171 } // namespace test | 169 } // namespace test |
172 } // namespace net | 170 } // namespace net |
OLD | NEW |