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

Side by Side Diff: net/spdy/spdy_test_util_common.cc

Issue 344253008: Stop using SpdySynReplyIR for SPDY 4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Additional test fix & SpdyTestUtil cleanup. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | net/spdy/spdy_websocket_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 const char* const extra_headers[], 1109 const char* const extra_headers[],
1110 int extra_header_count) { 1110 int extra_header_count) {
1111 SpdyHeadersIR headers(stream_id); 1111 SpdyHeadersIR headers(stream_id);
1112 headers.SetHeader(GetStatusKey(), "200 OK"); 1112 headers.SetHeader(GetStatusKey(), "200 OK");
1113 MaybeAddVersionHeader(&headers); 1113 MaybeAddVersionHeader(&headers);
1114 AppendToHeaderBlock(extra_headers, extra_header_count, 1114 AppendToHeaderBlock(extra_headers, extra_header_count,
1115 headers.mutable_name_value_block()); 1115 headers.mutable_name_value_block());
1116 return CreateFramer(false)->SerializeFrame(headers); 1116 return CreateFramer(false)->SerializeFrame(headers);
1117 } 1117 }
1118 1118
1119 SpdyFrame* SpdyTestUtil::ConstructSpdyReply(int stream_id,
1120 const SpdyHeaderBlock& headers) {
1121 if (protocol_ < kProtoSPDY4) {
1122 SpdySynReplyIR syn_reply(stream_id);
1123 syn_reply.set_name_value_block(headers);
1124 return CreateFramer(false)->SerializeFrame(syn_reply);
1125 } else {
1126 SpdyHeadersIR reply(stream_id);
1127 reply.set_name_value_block(headers);
1128 return CreateFramer(false)->SerializeFrame(reply);
1129 }
1130 }
1131
1119 SpdyFrame* SpdyTestUtil::ConstructSpdySynReplyError( 1132 SpdyFrame* SpdyTestUtil::ConstructSpdySynReplyError(
1120 const char* const status, 1133 const char* const status,
1121 const char* const* const extra_headers, 1134 const char* const* const extra_headers,
1122 int extra_header_count, 1135 int extra_header_count,
1123 int stream_id) { 1136 int stream_id) {
1124 SpdySynReplyIR syn_reply(stream_id); 1137 SpdyHeaderBlock block;
1125 syn_reply.SetHeader("hello", "bye"); 1138 block["hello"] = "bye";
1126 syn_reply.SetHeader(GetStatusKey(), status); 1139 block[GetStatusKey()] = status;
1127 MaybeAddVersionHeader(&syn_reply); 1140 MaybeAddVersionHeader(&block);
1128 AppendToHeaderBlock(extra_headers, extra_header_count, 1141 AppendToHeaderBlock(extra_headers, extra_header_count, &block);
1129 syn_reply.mutable_name_value_block()); 1142
1130 return CreateFramer(false)->SerializeFrame(syn_reply); 1143 return ConstructSpdyReply(stream_id, block);
1131 } 1144 }
1132 1145
1133 SpdyFrame* SpdyTestUtil::ConstructSpdyGetSynReplyRedirect(int stream_id) { 1146 SpdyFrame* SpdyTestUtil::ConstructSpdyGetSynReplyRedirect(int stream_id) {
1134 static const char* const kExtraHeaders[] = { 1147 static const char* const kExtraHeaders[] = {
1135 "location", "http://www.foo.com/index.php", 1148 "location", "http://www.foo.com/index.php",
1136 }; 1149 };
1137 return ConstructSpdySynReplyError("301 Moved Permanently", kExtraHeaders, 1150 return ConstructSpdySynReplyError("301 Moved Permanently", kExtraHeaders,
1138 arraysize(kExtraHeaders)/2, stream_id); 1151 arraysize(kExtraHeaders)/2, stream_id);
1139 } 1152 }
1140 1153
1141 SpdyFrame* SpdyTestUtil::ConstructSpdySynReplyError(int stream_id) { 1154 SpdyFrame* SpdyTestUtil::ConstructSpdySynReplyError(int stream_id) {
1142 return ConstructSpdySynReplyError("500 Internal Server Error", NULL, 0, 1); 1155 return ConstructSpdySynReplyError("500 Internal Server Error", NULL, 0, 1);
1143 } 1156 }
1144 1157
1145 SpdyFrame* SpdyTestUtil::ConstructSpdyGetSynReply( 1158 SpdyFrame* SpdyTestUtil::ConstructSpdyGetSynReply(
1146 const char* const extra_headers[], 1159 const char* const extra_headers[],
1147 int extra_header_count, 1160 int extra_header_count,
1148 int stream_id) { 1161 int stream_id) {
1149 SpdySynReplyIR syn_reply(stream_id); 1162 SpdyHeaderBlock block;
1150 syn_reply.SetHeader("hello", "bye"); 1163 block["hello"] = "bye";
1151 syn_reply.SetHeader(GetStatusKey(), "200"); 1164 block[GetStatusKey()] = "200";
1152 MaybeAddVersionHeader(&syn_reply); 1165 MaybeAddVersionHeader(&block);
1153 AppendToHeaderBlock(extra_headers, extra_header_count, 1166 AppendToHeaderBlock(extra_headers, extra_header_count, &block);
1154 syn_reply.mutable_name_value_block()); 1167
1155 return CreateFramer(false)->SerializeFrame(syn_reply); 1168 return ConstructSpdyReply(stream_id, block);
1156 } 1169 }
1157 1170
1158 SpdyFrame* SpdyTestUtil::ConstructSpdyPost(const char* url, 1171 SpdyFrame* SpdyTestUtil::ConstructSpdyPost(const char* url,
1159 SpdyStreamId stream_id, 1172 SpdyStreamId stream_id,
1160 int64 content_length, 1173 int64 content_length,
1161 RequestPriority priority, 1174 RequestPriority priority,
1162 const char* const extra_headers[], 1175 const char* const extra_headers[],
1163 int extra_header_count) { 1176 int extra_header_count) {
1164 const SpdyHeaderInfo kSynStartHeader = { 1177 const SpdyHeaderInfo kSynStartHeader = {
1165 SYN_STREAM, 1178 SYN_STREAM,
(...skipping 23 matching lines...) Expand all
1189 MaybeAddVersionHeader(&syn_stream); 1202 MaybeAddVersionHeader(&syn_stream);
1190 SetPriority(LOWEST, &syn_stream); 1203 SetPriority(LOWEST, &syn_stream);
1191 AppendToHeaderBlock(extra_headers, extra_header_count, 1204 AppendToHeaderBlock(extra_headers, extra_header_count,
1192 syn_stream.mutable_name_value_block()); 1205 syn_stream.mutable_name_value_block());
1193 return CreateFramer(false)->SerializeFrame(syn_stream); 1206 return CreateFramer(false)->SerializeFrame(syn_stream);
1194 } 1207 }
1195 1208
1196 SpdyFrame* SpdyTestUtil::ConstructSpdyPostSynReply( 1209 SpdyFrame* SpdyTestUtil::ConstructSpdyPostSynReply(
1197 const char* const extra_headers[], 1210 const char* const extra_headers[],
1198 int extra_header_count) { 1211 int extra_header_count) {
1199 SpdySynReplyIR syn_reply(1); 1212 // TODO(jgraettinger): Remove this method.
1200 syn_reply.SetHeader("hello", "bye"); 1213 return ConstructSpdyGetSynReply(NULL, 0, 1);
1201 syn_reply.SetHeader(GetStatusKey(), "200");
1202 syn_reply.SetHeader(GetPathKey(), "/index.php");
1203 MaybeAddVersionHeader(&syn_reply);
1204 AppendToHeaderBlock(extra_headers, extra_header_count,
1205 syn_reply.mutable_name_value_block());
1206 return CreateFramer(false)->SerializeFrame(syn_reply);
1207 } 1214 }
1208 1215
1209 SpdyFrame* SpdyTestUtil::ConstructSpdyBodyFrame(int stream_id, bool fin) { 1216 SpdyFrame* SpdyTestUtil::ConstructSpdyBodyFrame(int stream_id, bool fin) {
1210 SpdyFramer framer(spdy_version_); 1217 SpdyFramer framer(spdy_version_);
1211 SpdyDataIR data_ir(stream_id, 1218 SpdyDataIR data_ir(stream_id,
1212 base::StringPiece(kUploadData, kUploadDataSize)); 1219 base::StringPiece(kUploadData, kUploadDataSize));
1213 data_ir.set_fin(fin); 1220 data_ir.set_fin(fin);
1214 return framer.SerializeData(data_ir); 1221 return framer.SerializeData(data_ir);
1215 } 1222 }
1216 1223
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 return headers.Pass(); 1311 return headers.Pass();
1305 } 1312 }
1306 1313
1307 void SpdyTestUtil::MaybeAddVersionHeader( 1314 void SpdyTestUtil::MaybeAddVersionHeader(
1308 SpdyFrameWithNameValueBlockIR* frame_ir) const { 1315 SpdyFrameWithNameValueBlockIR* frame_ir) const {
1309 if (include_version_header()) { 1316 if (include_version_header()) {
1310 frame_ir->SetHeader(GetVersionKey(), "HTTP/1.1"); 1317 frame_ir->SetHeader(GetVersionKey(), "HTTP/1.1");
1311 } 1318 }
1312 } 1319 }
1313 1320
1321 void SpdyTestUtil::MaybeAddVersionHeader(SpdyHeaderBlock* block) const {
1322 if (include_version_header()) {
1323 (*block)[GetVersionKey()] = "HTTP/1.1";
1324 }
1325 }
1326
1314 void SpdyTestUtil::SetPriority(RequestPriority priority, 1327 void SpdyTestUtil::SetPriority(RequestPriority priority,
1315 SpdySynStreamIR* ir) const { 1328 SpdySynStreamIR* ir) const {
1316 ir->set_priority(ConvertRequestPriorityToSpdyPriority( 1329 ir->set_priority(ConvertRequestPriorityToSpdyPriority(
1317 priority, spdy_version())); 1330 priority, spdy_version()));
1318 } 1331 }
1319 1332
1320 } // namespace net 1333 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_common.h ('k') | net/spdy/spdy_websocket_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698