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

Unified Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 1604011: Use HttpRequestHeaders for extra_headers. (Closed)
Patch Set: Address eroman comments. Created 10 years, 8 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/http/partial_data.cc ('k') | net/spdy/spdy_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_network_transaction_unittest.cc
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc
index 377c7a5137bd9abb5ca1ac0ebf1b9f9366b8cfd0..2528d4bdc2f556286efeda49aca90ebf09086a37 100644
--- a/net/spdy/spdy_network_transaction_unittest.cc
+++ b/net/spdy/spdy_network_transaction_unittest.cc
@@ -500,46 +500,6 @@ int ConstructSpdyReply(const char* const extra_headers[],
return packet_size;
}
-// Construct a single SPDY header entry, for validation.
-// |extra_headers| are the extra header-value pairs.
-// |buffer| is the buffer we're filling in.
-// |index| is the index of the header we want.
-// Returns the number of bytes written into |buffer|.
-int ConstructSpdyHeader(const char* const extra_headers[],
- int extra_header_count,
- char* buffer,
- int buffer_length,
- int index) {
- const char* this_header = NULL;
- const char* this_value = NULL;
- if (!buffer || !buffer_length)
- return 0;
- *buffer = '\0';
- // Sanity check: Non-empty header list.
- DCHECK(NULL != extra_headers) << "NULL extra headers pointer";
- // Sanity check: Index out of range.
- DCHECK((index >= 0) && (index < extra_header_count))
- << "Index " << index
- << " out of range [0, " << extra_header_count << ")";
- this_header = extra_headers[index * 2];
- // Sanity check: Non-empty header.
- if (!*this_header)
- return 0;
- std::string::size_type header_len = strlen(this_header);
- if (!header_len)
- return 0;
- this_value = extra_headers[1 + (index * 2)];
- // Sanity check: Non-empty value.
- if (!*this_value)
- this_value = "";
- int n = base::snprintf(buffer,
- buffer_length,
- "%s: %s\r\n",
- this_header,
- this_value);
- return n;
-}
-
// Constructs a standard SPDY GET packet.
// |extra_headers| are the extra header-value pairs, which typically
// will vary the most between calls.
@@ -1169,9 +1129,8 @@ TEST_F(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
{
&syn_reply_info,
true,
- { 2, 4 },
- { { "cookie", "val1",
- "cookie", "val2",
+ { 1, 4 },
+ { { "cookie", "val1,val2",
NULL
},
{ "vary", "cookie",
@@ -1230,8 +1189,6 @@ TEST_F(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
- char modified_syn_header[64];
-
// Construct the request.
scoped_ptr<spdy::SpdyFrame> frame_req(
ConstructSpdyGet(test_cases[i].extra_headers[0],
@@ -1268,17 +1225,12 @@ TEST_F(SpdyNetworkTransactionTest, SynReplyHeadersVary) {
request.load_flags = 0;
// Attach the headers to the request.
- int hdrCount = test_cases[i].num_headers[0];
- int len = 0;
-
- for (int ct = 0; ct < hdrCount; ct++) {
- len = ConstructSpdyHeader(test_cases[i].extra_headers[0],
- test_cases[i].num_headers[0],
- modified_syn_header,
- 64,
- ct);
+ int header_count = test_cases[i].num_headers[0];
- request.extra_headers.append(modified_syn_header);
+ for (int ct = 0; ct < header_count; ct++) {
+ const char* header_key = test_cases[i].extra_headers[0][ct * 2];
+ const char* header_value = test_cases[i].extra_headers[0][ct * 2 + 1];
+ request.extra_headers.SetHeader(header_key, header_value);
}
scoped_refptr<DelayedSocketData> data(
« no previous file with comments | « net/http/partial_data.cc ('k') | net/spdy/spdy_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698