Index: net/quic/core/spdy_utils.cc |
diff --git a/net/quic/core/spdy_utils.cc b/net/quic/core/spdy_utils.cc |
index 987a3a1a9c46cf66a24a5751c91b9141a34c262c..64b781dbaddb43e15571c582624dbad85ea9e604 100644 |
--- a/net/quic/core/spdy_utils.cc |
+++ b/net/quic/core/spdy_utils.cc |
@@ -242,4 +242,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 |