Chromium Code Reviews| 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..e18a06563edb97e3c035aad1b04cd977f4be827e 100644 |
| --- a/net/spdy/spdy_test_util_spdy3.cc |
| +++ b/net/spdy/spdy_test_util_spdy3.cc |
| @@ -471,13 +471,15 @@ 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", |
| + /* |
| + ":path", "/somepath", |
| + ":host", "www.google.com", |
| + ":scheme", "http", |
| + */ |
| + ":status", "200", |
|
ramant (doing other things)
2012/03/30 22:19:58
nit: Please consider deleting commented out code.
Ryan Hamilton
2012/03/30 22:46:02
Whoops, sorry about that!
|
| + ":version", "HTTP/1.1" |
| }; |
| return ConstructSpdyControlFrame(extra_headers, |
| extra_header_count, |
| @@ -486,8 +488,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 +498,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'; |
| + |
|
ramant (doing other things)
2012/03/30 22:19:58
nit: please consider making a common method for co
Ryan Hamilton
2012/03/30 22:46:02
Agreed. I'll cook up a CL to do just that.
|
| + 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 +538,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 +550,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 +598,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 +633,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 +668,9 @@ SpdyFrame* ConstructSpdySynReplyError( |
| const char* const kStandardGetHeaders[] = { |
| "hello", |
| "bye", |
| - "status", |
| + ":status", |
| status, |
| - "version", |
| + ":version", |
| "HTTP/1.1" |
| }; |
| return ConstructSpdyControlFrame(extra_headers, |
| @@ -647,9 +717,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 +805,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 +872,11 @@ 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(), |
| + //next->first.length(), |
|
ramant (doing other things)
2012/03/30 22:19:58
nit: please consider deleting commented out code.
Ryan Hamilton
2012/03/30 22:46:02
Done.
|
| + strlen(header_string), |
| &buffer_write, |
| &buffer_left); |
| packet_size += AppendToBuffer(": ", |