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

Unified Diff: net/spdy/spdy_test_util_spdy3.cc

Issue 9958023: Properly handle spdy3 responses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 9 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_stream_spdy3_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_test_util_spdy3.cc
diff --git a/net/spdy/spdy_test_util_spdy3.cc b/net/spdy/spdy_test_util_spdy3.cc
index e5aaabfc711d29911695d7fe6ccd124d297062c4..56461668d564af962d29bdca3692eca34f378b0f 100644
--- a/net/spdy/spdy_test_util_spdy3.cc
+++ b/net/spdy/spdy_test_util_spdy3.cc
@@ -471,13 +471,10 @@ SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
int extra_header_count,
int stream_id,
int associated_stream_id) {
- const char* const kStandardGetHeaders[] = {
- "hello",
- "bye",
- "status",
- "200",
- "version",
- "HTTP/1.1"
+ const char* const kStandardPushHeaders[] = {
+ "hello", "bye",
+ ":status", "200",
+ ":version", "HTTP/1.1"
};
return ConstructSpdyControlFrame(extra_headers,
extra_header_count,
@@ -486,8 +483,8 @@ SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
LOWEST,
SYN_STREAM,
CONTROL_FLAG_NONE,
- kStandardGetHeaders,
- arraysize(kStandardGetHeaders),
+ kStandardPushHeaders,
+ arraysize(kStandardPushHeaders),
associated_stream_id);
}
@@ -496,15 +493,38 @@ SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
int stream_id,
int associated_stream_id,
const char* url) {
- const char* const kStandardGetHeaders[] = {
+ GURL gurl(url);
+
+ std::string str_path = gurl.PathForRequest();
+ std::string str_scheme = gurl.scheme();
+ std::string str_host = gurl.host();
+ if (gurl.has_port()) {
+ str_host += ":";
+ str_host += gurl.port();
+ }
+ scoped_array<char> req(new char[str_path.size() + 1]);
+ scoped_array<char> scheme(new char[str_scheme.size() + 1]);
+ scoped_array<char> host(new char[str_host.size() + 1]);
+ memcpy(req.get(), str_path.c_str(), str_path.size());
+ memcpy(scheme.get(), str_scheme.c_str(), str_scheme.size());
+ memcpy(host.get(), str_host.c_str(), str_host.size());
+ req.get()[str_path.size()] = '\0';
+ scheme.get()[str_scheme.size()] = '\0';
+ host.get()[str_host.size()] = '\0';
+
+ const char* const headers[] = {
"hello",
"bye",
- "status",
+ ":status",
"200 OK",
- "url",
- url,
- "version",
- "HTTP/1.1"
+ ":version",
+ "HTTP/1.1",
+ ":path",
+ req.get(),
+ ":host",
+ host.get(),
+ ":scheme",
+ scheme.get(),
};
return ConstructSpdyControlFrame(extra_headers,
extra_header_count,
@@ -513,8 +533,8 @@ SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
LOWEST,
SYN_STREAM,
CONTROL_FLAG_NONE,
- kStandardGetHeaders,
- arraysize(kStandardGetHeaders),
+ headers,
+ arraysize(headers),
associated_stream_id);
}
@@ -525,16 +545,39 @@ SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
const char* url,
const char* status,
const char* location) {
+ GURL gurl(url);
+
+ std::string str_path = gurl.PathForRequest();
+ std::string str_scheme = gurl.scheme();
+ std::string str_host = gurl.host();
+ if (gurl.has_port()) {
+ str_host += ":";
+ str_host += gurl.port();
+ }
+ scoped_array<char> req(new char[str_path.size() + 1]);
+ scoped_array<char> scheme(new char[str_scheme.size() + 1]);
+ scoped_array<char> host(new char[str_host.size() + 1]);
+ memcpy(req.get(), str_path.c_str(), str_path.size());
+ memcpy(scheme.get(), str_scheme.c_str(), str_scheme.size());
+ memcpy(host.get(), str_host.c_str(), str_host.size());
+ req.get()[str_path.size()] = '\0';
+ scheme.get()[str_scheme.size()] = '\0';
+ host.get()[str_host.size()] = '\0';
+
const char* const kStandardGetHeaders[] = {
"hello",
"bye",
- "status",
+ ":status",
status,
"location",
location,
- "url",
- url,
- "version",
+ ":path",
+ req.get(),
+ ":host",
+ host.get(),
+ ":scheme",
+ scheme.get(),
+ ":version",
"HTTP/1.1"
};
return ConstructSpdyControlFrame(extra_headers,
@@ -550,11 +593,33 @@ SpdyFrame* ConstructSpdyPush(const char* const extra_headers[],
}
SpdyFrame* ConstructSpdyPush(int stream_id,
- int associated_stream_id,
- const char* url) {
- const char* const kStandardGetHeaders[] = {
- "url",
- url
+ int associated_stream_id,
+ const char* url) {
+ GURL gurl(url);
+
+ std::string str_path = gurl.PathForRequest();
+ std::string str_scheme = gurl.scheme();
+ std::string str_host = gurl.host();
+ if (gurl.has_port()) {
+ str_host += ":";
+ str_host += gurl.port();
+ }
+ scoped_array<char> req(new char[str_path.size() + 1]);
+ scoped_array<char> scheme(new char[str_scheme.size() + 1]);
+ scoped_array<char> host(new char[str_host.size() + 1]);
+ memcpy(req.get(), str_path.c_str(), str_path.size());
+ memcpy(scheme.get(), str_scheme.c_str(), str_scheme.size());
+ memcpy(host.get(), str_host.c_str(), str_host.size());
+ req.get()[str_path.size()] = '\0';
+ scheme.get()[str_scheme.size()] = '\0';
+ host.get()[str_host.size()] = '\0';
+
+ const char* const headers[] = {
+ req.get(),
+ ":host",
+ host.get(),
+ ":scheme",
+ scheme.get(),
};
return ConstructSpdyControlFrame(0,
0,
@@ -563,18 +628,18 @@ SpdyFrame* ConstructSpdyPush(int stream_id,
LOWEST,
SYN_STREAM,
CONTROL_FLAG_NONE,
- kStandardGetHeaders,
- arraysize(kStandardGetHeaders),
+ headers,
+ arraysize(headers),
associated_stream_id);
}
SpdyFrame* ConstructSpdyPushHeaders(int stream_id,
- const char* const extra_headers[],
- int extra_header_count) {
+ const char* const extra_headers[],
+ int extra_header_count) {
const char* const kStandardGetHeaders[] = {
- "status",
+ ":status",
"200 OK",
- "version",
+ ":version",
"HTTP/1.1"
};
return ConstructSpdyControlFrame(extra_headers,
@@ -598,9 +663,9 @@ SpdyFrame* ConstructSpdySynReplyError(
const char* const kStandardGetHeaders[] = {
"hello",
"bye",
- "status",
+ ":status",
status,
- "version",
+ ":version",
"HTTP/1.1"
};
return ConstructSpdyControlFrame(extra_headers,
@@ -647,9 +712,9 @@ SpdyFrame* ConstructSpdyGetSynReply(const char* const extra_headers[],
static const char* const kStandardGetHeaders[] = {
"hello",
"bye",
- "status",
+ ":status",
"200",
- "version",
+ ":version",
"HTTP/1.1"
};
return ConstructSpdyControlFrame(extra_headers,
@@ -735,11 +800,11 @@ SpdyFrame* ConstructSpdyPostSynReply(const char* const extra_headers[],
static const char* const kStandardGetHeaders[] = {
"hello",
"bye",
- "status",
+ ":status",
"200",
"url",
"/index.php",
- "version",
+ ":version",
"HTTP/1.1"
};
return ConstructSpdyControlFrame(extra_headers,
@@ -802,8 +867,10 @@ int ConstructSpdyReplyString(const char* const extra_headers[],
// 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++;
packet_size += AppendToBuffer(header_string,
- next->first.length(),
+ strlen(header_string),
&buffer_write,
&buffer_left);
packet_size += AppendToBuffer(": ",
« no previous file with comments | « net/spdy/spdy_stream_spdy3_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698