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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_test_util_common.cc
diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc
index 3d73c7f0c59507f5fa1e198411eae51e8ac76cce..2b3a5516812364602aad92ca3bd24b4c6e364e68 100644
--- a/net/spdy/spdy_test_util_common.cc
+++ b/net/spdy/spdy_test_util_common.cc
@@ -1116,18 +1116,31 @@ SpdyFrame* SpdyTestUtil::ConstructSpdyPushHeaders(
return CreateFramer(false)->SerializeFrame(headers);
}
+SpdyFrame* SpdyTestUtil::ConstructSpdyReply(int stream_id,
+ const SpdyHeaderBlock& headers) {
+ if (protocol_ < kProtoSPDY4) {
+ SpdySynReplyIR syn_reply(stream_id);
+ syn_reply.set_name_value_block(headers);
+ return CreateFramer(false)->SerializeFrame(syn_reply);
+ } else {
+ SpdyHeadersIR reply(stream_id);
+ reply.set_name_value_block(headers);
+ return CreateFramer(false)->SerializeFrame(reply);
+ }
+}
+
SpdyFrame* SpdyTestUtil::ConstructSpdySynReplyError(
const char* const status,
const char* const* const extra_headers,
int extra_header_count,
int stream_id) {
- SpdySynReplyIR syn_reply(stream_id);
- syn_reply.SetHeader("hello", "bye");
- syn_reply.SetHeader(GetStatusKey(), status);
- MaybeAddVersionHeader(&syn_reply);
- AppendToHeaderBlock(extra_headers, extra_header_count,
- syn_reply.mutable_name_value_block());
- return CreateFramer(false)->SerializeFrame(syn_reply);
+ SpdyHeaderBlock block;
+ block["hello"] = "bye";
+ block[GetStatusKey()] = status;
+ MaybeAddVersionHeader(&block);
+ AppendToHeaderBlock(extra_headers, extra_header_count, &block);
+
+ return ConstructSpdyReply(stream_id, block);
}
SpdyFrame* SpdyTestUtil::ConstructSpdyGetSynReplyRedirect(int stream_id) {
@@ -1146,13 +1159,13 @@ SpdyFrame* SpdyTestUtil::ConstructSpdyGetSynReply(
const char* const extra_headers[],
int extra_header_count,
int stream_id) {
- SpdySynReplyIR syn_reply(stream_id);
- syn_reply.SetHeader("hello", "bye");
- syn_reply.SetHeader(GetStatusKey(), "200");
- MaybeAddVersionHeader(&syn_reply);
- AppendToHeaderBlock(extra_headers, extra_header_count,
- syn_reply.mutable_name_value_block());
- return CreateFramer(false)->SerializeFrame(syn_reply);
+ SpdyHeaderBlock block;
+ block["hello"] = "bye";
+ block[GetStatusKey()] = "200";
+ MaybeAddVersionHeader(&block);
+ AppendToHeaderBlock(extra_headers, extra_header_count, &block);
+
+ return ConstructSpdyReply(stream_id, block);
}
SpdyFrame* SpdyTestUtil::ConstructSpdyPost(const char* url,
@@ -1196,14 +1209,8 @@ SpdyFrame* SpdyTestUtil::ConstructChunkedSpdyPost(
SpdyFrame* SpdyTestUtil::ConstructSpdyPostSynReply(
const char* const extra_headers[],
int extra_header_count) {
- SpdySynReplyIR syn_reply(1);
- syn_reply.SetHeader("hello", "bye");
- syn_reply.SetHeader(GetStatusKey(), "200");
- syn_reply.SetHeader(GetPathKey(), "/index.php");
- MaybeAddVersionHeader(&syn_reply);
- AppendToHeaderBlock(extra_headers, extra_header_count,
- syn_reply.mutable_name_value_block());
- return CreateFramer(false)->SerializeFrame(syn_reply);
+ // TODO(jgraettinger): Remove this method.
+ return ConstructSpdyGetSynReply(NULL, 0, 1);
}
SpdyFrame* SpdyTestUtil::ConstructSpdyBodyFrame(int stream_id, bool fin) {
@@ -1311,6 +1318,12 @@ void SpdyTestUtil::MaybeAddVersionHeader(
}
}
+void SpdyTestUtil::MaybeAddVersionHeader(SpdyHeaderBlock* block) const {
+ if (include_version_header()) {
+ (*block)[GetVersionKey()] = "HTTP/1.1";
+ }
+}
+
void SpdyTestUtil::SetPriority(RequestPriority priority,
SpdySynStreamIR* ir) const {
ir->set_priority(ConvertRequestPriorityToSpdyPriority(
« 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