diff options
-rw-r--r-- | net/spdy/spdy_http_stream.cc | 5 | ||||
-rw-r--r-- | net/spdy/spdy_http_stream_unittest.cc | 2 | ||||
-rw-r--r-- | net/spdy/spdy_test_util.cc | 35 |
3 files changed, 37 insertions, 5 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc index 76358aa..b723b4e9 100644 --- a/net/spdy/spdy_http_stream.cc +++ b/net/spdy/spdy_http_stream.cc @@ -12,6 +12,7 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "net/base/load_flags.h" +#include "net/base/net_util.h" #include "net/http/http_request_info.h" #include "net/http/http_response_info.h" #include "net/http/http_util.h" @@ -111,7 +112,9 @@ void CreateSpdyHeadersFromHttpRequest( // TODO(mbelshe): Add authentication headers here. (*headers)["method"] = info.method; - (*headers)["url"] = net::HttpUtil::SpecForRequest(info.url); + (*headers)["url"] = net::HttpUtil::PathForRequest(info.url); + (*headers)["host"] = net::GetHostAndOptionalPort(info.url); + (*headers)["scheme"] = info.url.scheme(); (*headers)["version"] = kHttpProtocolVersion; if (!info.referrer.is_empty()) (*headers)["referer"] = info.referrer.spec(); diff --git a/net/spdy/spdy_http_stream_unittest.cc b/net/spdy/spdy_http_stream_unittest.cc index 1a3ece6..9faa795 100644 --- a/net/spdy/spdy_http_stream_unittest.cc +++ b/net/spdy/spdy_http_stream_unittest.cc @@ -125,7 +125,7 @@ TEST_F(SpdyHttpStreamTest, SpdyURLTest) { http_stream->stream()->spdy_headers().get(); EXPECT_TRUE(spdy_header != NULL); if (spdy_header->find("url") != spdy_header->end()) - EXPECT_EQ(base_url, spdy_header->find("url")->second); + EXPECT_EQ("/foo?query=what", spdy_header->find("url")->second); else FAIL() << "No url is set in spdy_header!"; diff --git a/net/spdy/spdy_test_util.cc b/net/spdy/spdy_test_util.cc index 291f2cd..97c87c0 100644 --- a/net/spdy/spdy_test_util.cc +++ b/net/spdy/spdy_test_util.cc @@ -269,11 +269,32 @@ spdy::SpdyFrame* ConstructSpdyGet(const char* const url, 0, // Length spdy::DATA_FLAG_NONE // Data Flags }; + + GURL gurl(url); + + // This is so ugly. Why are we using char* in here again? + std::string str_path = gurl.PathForRequest(); + std::string str_scheme = gurl.scheme(); + std::string str_host = gurl.host(); // TODO(mbelshe): should have a port. + scoped_ptr<char> req(new char[str_path.size() + 1]); + scoped_ptr<char> scheme(new char[str_scheme.size() + 1]); + scoped_ptr<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[] = { "method", "GET", "url", - url, + req.get(), + "host", + host.get(), + "scheme", + scheme.get(), "version", "HTTP/1.1" }; @@ -310,7 +331,11 @@ spdy::SpdyFrame* ConstructSpdyGet(const char* const extra_headers[], "method", "GET", "url", - "http://www.google.com/", + "/", + "host", + "www.google.com", + "scheme", + "http", "version", "HTTP/1.1" }; @@ -381,7 +406,11 @@ spdy::SpdyFrame* ConstructSpdyPost(const char* const extra_headers[], "method", "POST", "url", - "http://www.google.com/", + "/", + "host", + "www.google.com", + "scheme", + "http", "version", "HTTP/1.1" }; |