summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authorttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-20 03:50:56 +0000
committerttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-20 03:50:56 +0000
commit5fb3b32f802fd69bab30a742e1dda0521c4bed4b (patch)
treee3fc4aa73280f447608f1a7166e69992e98b23fe /net/spdy
parentf93e4f7f296fafe5367c9c8416bfe00e5af265f2 (diff)
downloadchromium_src-5fb3b32f802fd69bab30a742e1dda0521c4bed4b.zip
chromium_src-5fb3b32f802fd69bab30a742e1dda0521c4bed4b.tar.gz
chromium_src-5fb3b32f802fd69bab30a742e1dda0521c4bed4b.tar.bz2
Merge ConstructSpdyReplyString into SpdyTestUtil
BUG=226192 Review URL: https://chromiumcodereview.appspot.com/15332002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/spdy_network_transaction_spdy2_unittest.cc8
-rw-r--r--net/spdy/spdy_network_transaction_spdy3_unittest.cc8
-rw-r--r--net/spdy/spdy_test_util_common.cc73
-rw-r--r--net/spdy/spdy_test_util_common.h10
-rw-r--r--net/spdy/spdy_test_util_spdy2.cc71
-rw-r--r--net/spdy/spdy_test_util_spdy2.h10
-rw-r--r--net/spdy/spdy_test_util_spdy3.cc73
-rw-r--r--net/spdy/spdy_test_util_spdy3.h10
8 files changed, 91 insertions, 172 deletions
diff --git a/net/spdy/spdy_network_transaction_spdy2_unittest.cc b/net/spdy/spdy_network_transaction_spdy2_unittest.cc
index 2094d94..5090cd6 100644
--- a/net/spdy/spdy_network_transaction_spdy2_unittest.cc
+++ b/net/spdy/spdy_network_transaction_spdy2_unittest.cc
@@ -3495,10 +3495,10 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, SynReplyHeadersVary) {
// Construct the expected header reply string.
char reply_buffer[256] = "";
- ConstructSpdyReplyString(test_cases[i].extra_headers[1],
- test_cases[i].num_headers[1],
- reply_buffer,
- 256);
+ spdy_util_.ConstructSpdyReplyString(test_cases[i].extra_headers[1],
+ test_cases[i].num_headers[1],
+ reply_buffer,
+ 256);
EXPECT_EQ(std::string(reply_buffer), lines) << i;
}
diff --git a/net/spdy/spdy_network_transaction_spdy3_unittest.cc b/net/spdy/spdy_network_transaction_spdy3_unittest.cc
index bd433c0..6dffbd6 100644
--- a/net/spdy/spdy_network_transaction_spdy3_unittest.cc
+++ b/net/spdy/spdy_network_transaction_spdy3_unittest.cc
@@ -4082,10 +4082,10 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, SynReplyHeadersVary) {
// Construct the expected header reply string.
char reply_buffer[256] = "";
- ConstructSpdyReplyString(test_cases[i].extra_headers[1],
- test_cases[i].num_headers[1],
- reply_buffer,
- 256);
+ spdy_util_.ConstructSpdyReplyString(test_cases[i].extra_headers[1],
+ test_cases[i].num_headers[1],
+ reply_buffer,
+ 256);
EXPECT_EQ(std::string(reply_buffer), lines) << i;
}
diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc
index 696a01b..1b89045 100644
--- a/net/spdy/spdy_test_util_common.cc
+++ b/net/spdy/spdy_test_util_common.cc
@@ -667,6 +667,79 @@ SpdyFrame* SpdyTestUtil::ConstructSpdyControlFrame(
return ConstructSpdyFrame(header_info, headers.Pass());
}
+int SpdyTestUtil::ConstructSpdyReplyString(const char* const extra_headers[],
+ int extra_header_count,
+ char* buffer,
+ int buffer_length) const {
+ int frame_size = 0;
+ char* buffer_write = buffer;
+ int buffer_left = buffer_length;
+ SpdyHeaderBlock headers;
+ if (!buffer || !buffer_length)
+ return 0;
+ // Copy in the extra headers.
+ AppendToHeaderBlock(extra_headers, extra_header_count, &headers);
+ // The iterator gets us the list of header/value pairs in sorted order.
+ SpdyHeaderBlock::iterator next = headers.begin();
+ SpdyHeaderBlock::iterator last = headers.end();
+ for ( ; next != last; ++next) {
+ // Write the header.
+ int value_len, current_len, offset;
+ const char* header_string = next->first.c_str();
+ if (!is_spdy2() && header_string && header_string[0] == ':')
+ header_string++;
+ frame_size += AppendToBuffer(header_string,
+ strlen(header_string),
+ &buffer_write,
+ &buffer_left);
+ frame_size += AppendToBuffer(": ",
+ strlen(": "),
+ &buffer_write,
+ &buffer_left);
+ // Write the value(s).
+ const char* value_string = next->second.c_str();
+ // Check if it's split among two or more values.
+ value_len = next->second.length();
+ current_len = strlen(value_string);
+ offset = 0;
+ // Handle the first N-1 values.
+ while (current_len < value_len) {
+ // Finish this line -- write the current value.
+ frame_size += AppendToBuffer(value_string + offset,
+ current_len - offset,
+ &buffer_write,
+ &buffer_left);
+ frame_size += AppendToBuffer("\n",
+ strlen("\n"),
+ &buffer_write,
+ &buffer_left);
+ // Advance to next value.
+ offset = current_len + 1;
+ current_len += 1 + strlen(value_string + offset);
+ // Start another line -- add the header again.
+ frame_size += AppendToBuffer(header_string,
+ next->first.length(),
+ &buffer_write,
+ &buffer_left);
+ frame_size += AppendToBuffer(": ",
+ strlen(": "),
+ &buffer_write,
+ &buffer_left);
+ }
+ EXPECT_EQ(value_len, current_len);
+ // Copy the last (or only) value.
+ frame_size += AppendToBuffer(value_string + offset,
+ value_len - offset,
+ &buffer_write,
+ &buffer_left);
+ frame_size += AppendToBuffer("\n",
+ strlen("\n"),
+ &buffer_write,
+ &buffer_left);
+ }
+ return frame_size;
+}
+
SpdyFrame* SpdyTestUtil::ConstructSpdySettings(
const SettingsMap& settings) const {
return CreateFramer()->CreateSettings(settings);
diff --git a/net/spdy/spdy_test_util_common.h b/net/spdy/spdy_test_util_common.h
index 710c8e421..fbda727 100644
--- a/net/spdy/spdy_test_util_common.h
+++ b/net/spdy/spdy_test_util_common.h
@@ -319,6 +319,16 @@ class SpdyTestUtil {
int tail_headers_size,
SpdyStreamId associated_stream_id) const;
+ // Construct an expected SPDY reply string.
+ // |extra_headers| are the extra header-value pairs, which typically
+ // will vary the most between calls.
+ // |buffer| is the buffer we're filling in.
+ // Returns the number of bytes written into |buffer|.
+ int ConstructSpdyReplyString(const char* const extra_headers[],
+ int extra_header_count,
+ char* buffer,
+ int buffer_length) const;
+
// Construct an expected SPDY SETTINGS frame.
// |settings| are the settings to set.
// Returns the constructed frame. The caller takes ownership of the frame.
diff --git a/net/spdy/spdy_test_util_spdy2.cc b/net/spdy/spdy_test_util_spdy2.cc
index 9afc9da..dfd1051 100644
--- a/net/spdy/spdy_test_util_spdy2.cc
+++ b/net/spdy/spdy_test_util_spdy2.cc
@@ -422,77 +422,6 @@ SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame,
frame->size(), false);
}
-int ConstructSpdyReplyString(const char* const extra_headers[],
- int extra_header_count,
- char* buffer,
- int buffer_length) {
- int frame_size = 0;
- char* buffer_write = buffer;
- int buffer_left = buffer_length;
- SpdyHeaderBlock headers;
- if (!buffer || !buffer_length)
- return 0;
- // Copy in the extra headers.
- AppendToHeaderBlock(extra_headers, extra_header_count, &headers);
- // The iterator gets us the list of header/value pairs in sorted order.
- SpdyHeaderBlock::iterator next = headers.begin();
- SpdyHeaderBlock::iterator last = headers.end();
- for ( ; next != last; ++next) {
- // Write the header.
- int value_len, current_len, offset;
- const char* header_string = next->first.c_str();
- frame_size += AppendToBuffer(header_string,
- next->first.length(),
- &buffer_write,
- &buffer_left);
- frame_size += AppendToBuffer(": ",
- strlen(": "),
- &buffer_write,
- &buffer_left);
- // Write the value(s).
- const char* value_string = next->second.c_str();
- // Check if it's split among two or more values.
- value_len = next->second.length();
- current_len = strlen(value_string);
- offset = 0;
- // Handle the first N-1 values.
- while (current_len < value_len) {
- // Finish this line -- write the current value.
- frame_size += AppendToBuffer(value_string + offset,
- current_len - offset,
- &buffer_write,
- &buffer_left);
- frame_size += AppendToBuffer("\n",
- strlen("\n"),
- &buffer_write,
- &buffer_left);
- // Advance to next value.
- offset = current_len + 1;
- current_len += 1 + strlen(value_string + offset);
- // Start another line -- add the header again.
- frame_size += AppendToBuffer(header_string,
- next->first.length(),
- &buffer_write,
- &buffer_left);
- frame_size += AppendToBuffer(": ",
- strlen(": "),
- &buffer_write,
- &buffer_left);
- }
- EXPECT_EQ(value_len, current_len);
- // Copy the last (or only) value.
- frame_size += AppendToBuffer(value_string + offset,
- value_len - offset,
- &buffer_write,
- &buffer_left);
- frame_size += AppendToBuffer("\n",
- strlen("\n"),
- &buffer_write,
- &buffer_left);
- }
- return frame_size;
-}
-
const SpdyHeaderInfo MakeSpdyHeader(SpdyFrameType type) {
const SpdyHeaderInfo kHeader = {
type, // Kind = Syn
diff --git a/net/spdy/spdy_test_util_spdy2.h b/net/spdy/spdy_test_util_spdy2.h
index 2b2a207..3630b13 100644
--- a/net/spdy/spdy_test_util_spdy2.h
+++ b/net/spdy/spdy_test_util_spdy2.h
@@ -24,16 +24,6 @@ namespace test_spdy2 {
// Can't find a function you're looking for? ttuttle is migrating functions
// from here into methods in the SpdyTestUtil class in spdy_test_common.h.
-// Construct an expected SPDY reply string.
-// |extra_headers| are the extra header-value pairs, which typically
-// will vary the most between calls.
-// |buffer| is the buffer we're filling in.
-// Returns the number of bytes written into |buffer|.
-int ConstructSpdyReplyString(const char* const extra_headers[],
- int extra_header_count,
- char* buffer,
- int buffer_length);
-
// Construct a single SPDY header entry, for validation.
// |extra_headers| are the extra header-value pairs.
// |buffer| is the buffer we're filling in.
diff --git a/net/spdy/spdy_test_util_spdy3.cc b/net/spdy/spdy_test_util_spdy3.cc
index 2c52214..e7416b0 100644
--- a/net/spdy/spdy_test_util_spdy3.cc
+++ b/net/spdy/spdy_test_util_spdy3.cc
@@ -488,79 +488,6 @@ SpdyFrame* ConstructWrappedSpdyFrame(const scoped_ptr<SpdyFrame>& frame,
false);
}
-int ConstructSpdyReplyString(const char* const extra_headers[],
- int extra_header_count,
- char* buffer,
- int buffer_length) {
- int frame_size = 0;
- char* buffer_write = buffer;
- int buffer_left = buffer_length;
- SpdyHeaderBlock headers;
- if (!buffer || !buffer_length)
- return 0;
- // Copy in the extra headers.
- AppendToHeaderBlock(extra_headers, extra_header_count, &headers);
- // The iterator gets us the list of header/value pairs in sorted order.
- SpdyHeaderBlock::iterator next = headers.begin();
- SpdyHeaderBlock::iterator last = headers.end();
- for ( ; next != last; ++next) {
- // Write the header.
- int value_len, current_len, offset;
- const char* header_string = next->first.c_str();
- if (header_string && header_string[0] == ':')
- header_string++;
- frame_size += AppendToBuffer(header_string,
- strlen(header_string),
- &buffer_write,
- &buffer_left);
- frame_size += AppendToBuffer(": ",
- strlen(": "),
- &buffer_write,
- &buffer_left);
- // Write the value(s).
- const char* value_string = next->second.c_str();
- // Check if it's split among two or more values.
- value_len = next->second.length();
- current_len = strlen(value_string);
- offset = 0;
- // Handle the first N-1 values.
- while (current_len < value_len) {
- // Finish this line -- write the current value.
- frame_size += AppendToBuffer(value_string + offset,
- current_len - offset,
- &buffer_write,
- &buffer_left);
- frame_size += AppendToBuffer("\n",
- strlen("\n"),
- &buffer_write,
- &buffer_left);
- // Advance to next value.
- offset = current_len + 1;
- current_len += 1 + strlen(value_string + offset);
- // Start another line -- add the header again.
- frame_size += AppendToBuffer(header_string,
- next->first.length(),
- &buffer_write,
- &buffer_left);
- frame_size += AppendToBuffer(": ",
- strlen(": "),
- &buffer_write,
- &buffer_left);
- }
- EXPECT_EQ(value_len, current_len);
- // Copy the last (or only) value.
- frame_size += AppendToBuffer(value_string + offset,
- value_len - offset,
- &buffer_write,
- &buffer_left);
- frame_size += AppendToBuffer("\n",
- strlen("\n"),
- &buffer_write,
- &buffer_left);
- }
- return frame_size;
-}
-
const SpdyHeaderInfo MakeSpdyHeader(SpdyFrameType type) {
const SpdyHeaderInfo kHeader = {
type, // Kind = Syn
diff --git a/net/spdy/spdy_test_util_spdy3.h b/net/spdy/spdy_test_util_spdy3.h
index 5204f72..b8dbe88 100644
--- a/net/spdy/spdy_test_util_spdy3.h
+++ b/net/spdy/spdy_test_util_spdy3.h
@@ -28,16 +28,6 @@ namespace test_spdy3 {
// Can't find a function you're looking for? ttuttle is migrating functions
// from here into methods in the SpdyTestUtil class in spdy_test_common.h.
-// Construct an expected SPDY reply string.
-// |extra_headers| are the extra header-value pairs, which typically
-// will vary the most between calls.
-// |buffer| is the buffer we're filling in.
-// Returns the number of bytes written into |buffer|.
-int ConstructSpdyReplyString(const char* const extra_headers[],
- int extra_header_count,
- char* buffer,
- int buffer_length);
-
// Construct a single SPDY header entry, for validation.
// |extra_headers| are the extra header-value pairs.
// |buffer| is the buffer we're filling in.