Index: net/spdy/spdy_http_utils.cc |
diff --git a/net/spdy/spdy_http_utils.cc b/net/spdy/spdy_http_utils.cc |
index c604880473c7c41666bf79e5b8a87e52033ceaf1..dcd120fd77dbcd1f78766b586cb020edb1cf3677 100644 |
--- a/net/spdy/spdy_http_utils.cc |
+++ b/net/spdy/spdy_http_utils.cc |
@@ -183,28 +183,22 @@ NET_EXPORT_PRIVATE RequestPriority ConvertSpdyPriorityToRequestPriority( |
GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers, |
SpdyMajorVersion protocol_version, |
bool pushed) { |
- const char* scheme_header = protocol_version >= SPDY3 ? ":scheme" : "scheme"; |
- const char* host_header = protocol_version >= SPDY4 ? ":authority" : |
- (protocol_version >= SPDY3 ? ":host" : "host"); |
- const char* path_header = protocol_version >= SPDY3 ? ":path" : "url"; |
- |
- std::string scheme; |
- std::string host_port; |
- std::string path; |
- SpdyHeaderBlock::const_iterator it; |
- it = headers.find(scheme_header); |
- if (it != headers.end()) |
- scheme = it->second; |
- it = headers.find(host_header); |
- if (it != headers.end()) |
- host_port = it->second; |
- it = headers.find(path_header); |
- if (it != headers.end()) |
- path = it->second; |
- |
- std::string url = (scheme.empty() || host_port.empty() || path.empty()) |
- ? std::string() |
- : scheme + "://" + host_port + path; |
+ DCHECK_LE(SPDY3, protocol_version); |
+ SpdyHeaderBlock::const_iterator it = headers.find(":scheme"); |
+ if (it == headers.end()) |
+ return GURL(); |
+ std::string url = it->second; |
+ url.append("://"); |
+ |
+ it = headers.find(protocol_version >= SPDY4 ? ":authority" : ":host"); |
+ if (it == headers.end()) |
+ return GURL(); |
+ url.append(it->second); |
+ |
+ it = headers.find(":path"); |
+ if (it == headers.end()) |
+ return GURL(); |
+ url.append(it->second); |
return GURL(url); |
} |