Index: net/quic/core/spdy_utils.cc |
diff --git a/net/quic/core/spdy_utils.cc b/net/quic/core/spdy_utils.cc |
index 9ed8642a4aeca9f8307fa75a8f1253551e8ec79d..602f4b5308ca26cacdce271c201ff68d442f3dcc 100644 |
--- a/net/quic/core/spdy_utils.cc |
+++ b/net/quic/core/spdy_utils.cc |
@@ -261,4 +261,23 @@ bool SpdyUtils::UrlIsValid(const SpdyHeaderBlock& headers) { |
return url != "" && GURL(url).is_valid(); |
} |
+// static |
+bool SpdyUtils::PopulateHeaderBlockFromUrl(const string url, |
+ SpdyHeaderBlock* headers) { |
+ (*headers)[":method"] = "GET"; |
+ size_t pos = url.find("://"); |
+ if (pos == string::npos) { |
+ return false; |
+ } |
+ (*headers)[":scheme"] = url.substr(0, pos); |
+ size_t start = pos + 3; |
+ pos = url.find("/", start); |
+ if (pos == string::npos) { |
+ return false; |
+ } |
+ (*headers)[":authority"] = url.substr(start, pos - start); |
+ (*headers)[":path"] = url.substr(pos); |
+ return true; |
+} |
+ |
} // namespace net |