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(": ", |