| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 | 10 |
| (...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 return ConstructSpdySyn( | 946 return ConstructSpdySyn( |
| 947 stream_id, *block, request_priority, compressed, true); | 947 stream_id, *block, request_priority, compressed, true); |
| 948 } | 948 } |
| 949 | 949 |
| 950 SpdyFrame* SpdyTestUtil::ConstructSpdyGet(const char* const extra_headers[], | 950 SpdyFrame* SpdyTestUtil::ConstructSpdyGet(const char* const extra_headers[], |
| 951 int extra_header_count, | 951 int extra_header_count, |
| 952 bool compressed, | 952 bool compressed, |
| 953 int stream_id, | 953 int stream_id, |
| 954 RequestPriority request_priority, | 954 RequestPriority request_priority, |
| 955 bool direct) { | 955 bool direct) { |
| 956 return ConstructSpdyGet(extra_headers, extra_header_count, compressed, |
| 957 stream_id, request_priority, direct, true); |
| 958 } |
| 959 |
| 960 SpdyFrame* SpdyTestUtil::ConstructSpdyGet(const char* const extra_headers[], |
| 961 int extra_header_count, |
| 962 bool compressed, |
| 963 int stream_id, |
| 964 RequestPriority request_priority, |
| 965 bool direct, |
| 966 bool fin) { |
| 956 SpdyHeaderBlock block; | 967 SpdyHeaderBlock block; |
| 957 MaybeAddVersionHeader(&block); | 968 MaybeAddVersionHeader(&block); |
| 958 block[GetMethodKey()] = "GET"; | 969 block[GetMethodKey()] = "GET"; |
| 959 AddUrlToHeaderBlock(default_url_.spec(), &block); | 970 AddUrlToHeaderBlock(default_url_.spec(), &block); |
| 960 AppendToHeaderBlock(extra_headers, extra_header_count, &block); | 971 AppendToHeaderBlock(extra_headers, extra_header_count, &block); |
| 961 return ConstructSpdySyn(stream_id, block, request_priority, compressed, true); | 972 return ConstructSpdySyn(stream_id, block, request_priority, compressed, fin); |
| 962 } | 973 } |
| 963 | 974 |
| 964 SpdyFrame* SpdyTestUtil::ConstructSpdyConnect( | 975 SpdyFrame* SpdyTestUtil::ConstructSpdyConnect( |
| 965 const char* const extra_headers[], | 976 const char* const extra_headers[], |
| 966 int extra_header_count, | 977 int extra_header_count, |
| 967 int stream_id, | 978 int stream_id, |
| 968 RequestPriority priority, | 979 RequestPriority priority, |
| 969 const HostPortPair& host_port_pair) { | 980 const HostPortPair& host_port_pair) { |
| 970 SpdyHeaderBlock block; | 981 SpdyHeaderBlock block; |
| 971 MaybeAddVersionHeader(&block); | 982 MaybeAddVersionHeader(&block); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 headers.SetHeader(GetStatusKey(), "200 OK"); | 1104 headers.SetHeader(GetStatusKey(), "200 OK"); |
| 1094 MaybeAddVersionHeader(&headers); | 1105 MaybeAddVersionHeader(&headers); |
| 1095 AppendToHeaderBlock(extra_headers, extra_header_count, | 1106 AppendToHeaderBlock(extra_headers, extra_header_count, |
| 1096 headers.mutable_header_block()); | 1107 headers.mutable_header_block()); |
| 1097 return CreateFramer(false)->SerializeFrame(headers); | 1108 return CreateFramer(false)->SerializeFrame(headers); |
| 1098 } | 1109 } |
| 1099 | 1110 |
| 1100 SpdyFrame* SpdyTestUtil::ConstructSpdyHeaderFrame(int stream_id, | 1111 SpdyFrame* SpdyTestUtil::ConstructSpdyHeaderFrame(int stream_id, |
| 1101 const char* const headers[], | 1112 const char* const headers[], |
| 1102 int header_count) { | 1113 int header_count) { |
| 1114 return ConstructSpdyHeaderFrame(stream_id, headers, header_count, false); |
| 1115 } |
| 1116 |
| 1117 SpdyFrame* SpdyTestUtil::ConstructSpdyHeaderFrame(int stream_id, |
| 1118 const char* const headers[], |
| 1119 int header_count, |
| 1120 bool fin) { |
| 1103 SpdyHeadersIR spdy_headers(stream_id); | 1121 SpdyHeadersIR spdy_headers(stream_id); |
| 1122 spdy_headers.set_fin(fin); |
| 1104 AppendToHeaderBlock(headers, header_count, | 1123 AppendToHeaderBlock(headers, header_count, |
| 1105 spdy_headers.mutable_header_block()); | 1124 spdy_headers.mutable_header_block()); |
| 1106 return CreateFramer(false)->SerializeFrame(spdy_headers); | 1125 return CreateFramer(false)->SerializeFrame(spdy_headers); |
| 1107 } | 1126 } |
| 1108 | 1127 |
| 1109 SpdyFrame* SpdyTestUtil::ConstructSpdySyn(int stream_id, | 1128 SpdyFrame* SpdyTestUtil::ConstructSpdySyn(int stream_id, |
| 1110 const SpdyHeaderBlock& block, | 1129 const SpdyHeaderBlock& block, |
| 1111 RequestPriority priority, | 1130 RequestPriority priority, |
| 1112 bool compressed, | 1131 bool compressed, |
| 1113 bool fin) { | 1132 bool fin) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 block[GetMethodKey()] = "POST"; | 1237 block[GetMethodKey()] = "POST"; |
| 1219 AddUrlToHeaderBlock(default_url_.spec(), &block); | 1238 AddUrlToHeaderBlock(default_url_.spec(), &block); |
| 1220 AppendToHeaderBlock(extra_headers, extra_header_count, &block); | 1239 AppendToHeaderBlock(extra_headers, extra_header_count, &block); |
| 1221 return ConstructSpdySyn(1, block, LOWEST, false, false); | 1240 return ConstructSpdySyn(1, block, LOWEST, false, false); |
| 1222 } | 1241 } |
| 1223 | 1242 |
| 1224 SpdyFrame* SpdyTestUtil::ConstructSpdyPostSynReply( | 1243 SpdyFrame* SpdyTestUtil::ConstructSpdyPostSynReply( |
| 1225 const char* const extra_headers[], | 1244 const char* const extra_headers[], |
| 1226 int extra_header_count) { | 1245 int extra_header_count) { |
| 1227 // TODO(jgraettinger): Remove this method. | 1246 // TODO(jgraettinger): Remove this method. |
| 1228 return ConstructSpdyGetSynReply(NULL, 0, 1); | 1247 return ConstructSpdyGetSynReply(extra_headers, extra_header_count, 1); |
| 1229 } | 1248 } |
| 1230 | 1249 |
| 1231 SpdyFrame* SpdyTestUtil::ConstructSpdyBodyFrame(int stream_id, bool fin) { | 1250 SpdyFrame* SpdyTestUtil::ConstructSpdyBodyFrame(int stream_id, bool fin) { |
| 1232 SpdyFramer framer(spdy_version_); | 1251 SpdyFramer framer(spdy_version_); |
| 1233 SpdyDataIR data_ir(stream_id, | 1252 SpdyDataIR data_ir(stream_id, |
| 1234 base::StringPiece(kUploadData, kUploadDataSize)); | 1253 base::StringPiece(kUploadData, kUploadDataSize)); |
| 1235 data_ir.set_fin(fin); | 1254 data_ir.set_fin(fin); |
| 1236 return framer.SerializeData(data_ir); | 1255 return framer.SerializeData(data_ir); |
| 1237 } | 1256 } |
| 1238 | 1257 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 } | 1365 } |
| 1347 } | 1366 } |
| 1348 | 1367 |
| 1349 void SpdyTestUtil::SetPriority(RequestPriority priority, | 1368 void SpdyTestUtil::SetPriority(RequestPriority priority, |
| 1350 SpdySynStreamIR* ir) const { | 1369 SpdySynStreamIR* ir) const { |
| 1351 ir->set_priority(ConvertRequestPriorityToSpdyPriority( | 1370 ir->set_priority(ConvertRequestPriorityToSpdyPriority( |
| 1352 priority, spdy_version())); | 1371 priority, spdy_version())); |
| 1353 } | 1372 } |
| 1354 | 1373 |
| 1355 } // namespace net | 1374 } // namespace net |
| OLD | NEW |