OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_util_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 NextProtoVector SpdyNextProtos() { | 54 NextProtoVector SpdyNextProtos() { |
55 NextProtoVector next_protos; | 55 NextProtoVector next_protos; |
56 next_protos.push_back(kProtoHTTP11); | 56 next_protos.push_back(kProtoHTTP11); |
57 next_protos.push_back(kProtoDeprecatedSPDY2); | 57 next_protos.push_back(kProtoDeprecatedSPDY2); |
58 next_protos.push_back(kProtoSPDY3); | 58 next_protos.push_back(kProtoSPDY3); |
59 next_protos.push_back(kProtoSPDY31); | 59 next_protos.push_back(kProtoSPDY31); |
60 next_protos.push_back(kProtoSPDY4); | 60 next_protos.push_back(kProtoSPDY4_14); |
| 61 next_protos.push_back(kProtoSPDY4_15); |
61 next_protos.push_back(kProtoQUIC1SPDY3); | 62 next_protos.push_back(kProtoQUIC1SPDY3); |
62 return next_protos; | 63 return next_protos; |
63 } | 64 } |
64 | 65 |
65 // Chop a frame into an array of MockWrites. | 66 // Chop a frame into an array of MockWrites. |
66 // |data| is the frame to chop. | 67 // |data| is the frame to chop. |
67 // |length| is the length of the frame to chop. | 68 // |length| is the length of the frame to chop. |
68 // |num_chunks| is the number of chunks to create. | 69 // |num_chunks| is the number of chunks to create. |
69 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) { | 70 MockWrite* ChopWriteFrame(const char* data, int length, int num_chunks) { |
70 MockWrite* chunks = new MockWrite[num_chunks]; | 71 MockWrite* chunks = new MockWrite[num_chunks]; |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 AppendToHeaderBlock(extra_headers, extra_header_count, | 1101 AppendToHeaderBlock(extra_headers, extra_header_count, |
1101 headers.mutable_name_value_block()); | 1102 headers.mutable_name_value_block()); |
1102 return CreateFramer(false)->SerializeFrame(headers); | 1103 return CreateFramer(false)->SerializeFrame(headers); |
1103 } | 1104 } |
1104 | 1105 |
1105 SpdyFrame* SpdyTestUtil::ConstructSpdySyn(int stream_id, | 1106 SpdyFrame* SpdyTestUtil::ConstructSpdySyn(int stream_id, |
1106 const SpdyHeaderBlock& block, | 1107 const SpdyHeaderBlock& block, |
1107 RequestPriority priority, | 1108 RequestPriority priority, |
1108 bool compressed, | 1109 bool compressed, |
1109 bool fin) const { | 1110 bool fin) const { |
1110 if (protocol_ < kProtoSPDY4) { | 1111 if (protocol_ < kProtoSPDY4MinimumVersion) { |
1111 SpdySynStreamIR syn_stream(stream_id); | 1112 SpdySynStreamIR syn_stream(stream_id); |
1112 syn_stream.set_name_value_block(block); | 1113 syn_stream.set_name_value_block(block); |
1113 syn_stream.set_priority( | 1114 syn_stream.set_priority( |
1114 ConvertRequestPriorityToSpdyPriority(priority, spdy_version())); | 1115 ConvertRequestPriorityToSpdyPriority(priority, spdy_version())); |
1115 syn_stream.set_fin(fin); | 1116 syn_stream.set_fin(fin); |
1116 return CreateFramer(compressed)->SerializeFrame(syn_stream); | 1117 return CreateFramer(compressed)->SerializeFrame(syn_stream); |
1117 } else { | 1118 } else { |
1118 SpdyHeadersIR headers(stream_id); | 1119 SpdyHeadersIR headers(stream_id); |
1119 headers.set_name_value_block(block); | 1120 headers.set_name_value_block(block); |
1120 headers.set_has_priority(true); | 1121 headers.set_has_priority(true); |
1121 headers.set_priority( | 1122 headers.set_priority( |
1122 ConvertRequestPriorityToSpdyPriority(priority, spdy_version())); | 1123 ConvertRequestPriorityToSpdyPriority(priority, spdy_version())); |
1123 headers.set_fin(fin); | 1124 headers.set_fin(fin); |
1124 return CreateFramer(compressed)->SerializeFrame(headers); | 1125 return CreateFramer(compressed)->SerializeFrame(headers); |
1125 } | 1126 } |
1126 } | 1127 } |
1127 | 1128 |
1128 SpdyFrame* SpdyTestUtil::ConstructSpdyReply(int stream_id, | 1129 SpdyFrame* SpdyTestUtil::ConstructSpdyReply(int stream_id, |
1129 const SpdyHeaderBlock& headers) { | 1130 const SpdyHeaderBlock& headers) { |
1130 if (protocol_ < kProtoSPDY4) { | 1131 if (protocol_ < kProtoSPDY4MinimumVersion) { |
1131 SpdySynReplyIR syn_reply(stream_id); | 1132 SpdySynReplyIR syn_reply(stream_id); |
1132 syn_reply.set_name_value_block(headers); | 1133 syn_reply.set_name_value_block(headers); |
1133 return CreateFramer(false)->SerializeFrame(syn_reply); | 1134 return CreateFramer(false)->SerializeFrame(syn_reply); |
1134 } else { | 1135 } else { |
1135 SpdyHeadersIR reply(stream_id); | 1136 SpdyHeadersIR reply(stream_id); |
1136 reply.set_name_value_block(headers); | 1137 reply.set_name_value_block(headers); |
1137 return CreateFramer(false)->SerializeFrame(reply); | 1138 return CreateFramer(false)->SerializeFrame(reply); |
1138 } | 1139 } |
1139 } | 1140 } |
1140 | 1141 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 return is_spdy2() ? "method" : ":method"; | 1262 return is_spdy2() ? "method" : ":method"; |
1262 } | 1263 } |
1263 | 1264 |
1264 const char* SpdyTestUtil::GetStatusKey() const { | 1265 const char* SpdyTestUtil::GetStatusKey() const { |
1265 return is_spdy2() ? "status" : ":status"; | 1266 return is_spdy2() ? "status" : ":status"; |
1266 } | 1267 } |
1267 | 1268 |
1268 const char* SpdyTestUtil::GetHostKey() const { | 1269 const char* SpdyTestUtil::GetHostKey() const { |
1269 if (protocol_ < kProtoSPDY3) | 1270 if (protocol_ < kProtoSPDY3) |
1270 return "host"; | 1271 return "host"; |
1271 if (protocol_ < kProtoSPDY4) | 1272 if (protocol_ < kProtoSPDY4MinimumVersion) |
1272 return ":host"; | 1273 return ":host"; |
1273 else | 1274 else |
1274 return ":authority"; | 1275 return ":authority"; |
1275 } | 1276 } |
1276 | 1277 |
1277 const char* SpdyTestUtil::GetSchemeKey() const { | 1278 const char* SpdyTestUtil::GetSchemeKey() const { |
1278 return is_spdy2() ? "scheme" : ":scheme"; | 1279 return is_spdy2() ? "scheme" : ":scheme"; |
1279 } | 1280 } |
1280 | 1281 |
1281 const char* SpdyTestUtil::GetVersionKey() const { | 1282 const char* SpdyTestUtil::GetVersionKey() const { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 } | 1321 } |
1321 } | 1322 } |
1322 | 1323 |
1323 void SpdyTestUtil::SetPriority(RequestPriority priority, | 1324 void SpdyTestUtil::SetPriority(RequestPriority priority, |
1324 SpdySynStreamIR* ir) const { | 1325 SpdySynStreamIR* ir) const { |
1325 ir->set_priority(ConvertRequestPriorityToSpdyPriority( | 1326 ir->set_priority(ConvertRequestPriorityToSpdyPriority( |
1326 priority, spdy_version())); | 1327 priority, spdy_version())); |
1327 } | 1328 } |
1328 | 1329 |
1329 } // namespace net | 1330 } // namespace net |
OLD | NEW |