Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1863)

Unified Diff: net/spdy/spdy_stream.cc

Issue 9705046: Switch CreateSpdyHeadersFromHttpRequest to construct the correct headers based on the spdy protocol… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/spdy/spdy_stream.cc
diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc
index 3280d005872feb0621086cfbe6b697c26a1ffb18..0f20a853a389081521d0e1154f782787321b745f 100644
--- a/net/spdy/spdy_stream.cc
+++ b/net/spdy/spdy_stream.cc
@@ -440,6 +440,10 @@ void SpdyStream::OnChunkAvailable() {
OnWriteComplete(0);
}
+int SpdyStream::GetProtocolVersion() const {
+ return session_->GetProtocolVersion();
+}
+
void SpdyStream::LogStreamError(int status, const std::string& description) {
net_log_.AddEvent(
NetLog::TYPE_SPDY_STREAM_ERROR,
@@ -516,28 +520,40 @@ GURL SpdyStream::GetUrl() const {
DCHECK(HasUrl());
if (pushed_) {
- // assemble from the response
- std::string url;
- spdy::SpdyHeaderBlock::const_iterator it;
- it = response_->find("url");
- if (it != (*response_).end())
- url = it->second;
- return GURL(url);
+ if (GetProtocolVersion() >= 3) {
+ return GetUrlFromHeaderBlock(response_);
+ } else {
+ // assemble from the response
+ std::string url;
+ spdy::SpdyHeaderBlock::const_iterator it;
+ it = response_->find("url");
+ if (it != (*response_).end())
+ url = it->second;
+ return GURL(url);
+ }
}
- // assemble from the request
+ return GetUrlFromHeaderBlock(request_);
+}
+
+GURL SpdyStream::GetUrlFromHeaderBlock(
+ const linked_ptr<spdy::SpdyHeaderBlock>& headers) const {
+ const char* scheme_header = GetProtocolVersion() >= 3 ? ":scheme" : "scheme";
+ const char* host_header = GetProtocolVersion() >= 3 ? ":host" : "host";
+ const char* path_header = GetProtocolVersion() >= 3 ? ":path" : "path";
+
std::string scheme;
std::string host_port;
std::string path;
spdy::SpdyHeaderBlock::const_iterator it;
- it = request_->find("scheme");
- if (it != (*request_).end())
+ it = headers->find(scheme_header);
+ if (it != (*headers).end())
scheme = it->second;
- it = request_->find("host");
- if (it != (*request_).end())
+ it = headers->find(host_header);
+ if (it != (*headers).end())
host_port = it->second;
- it = request_->find("path");
- if (it != (*request_).end())
+ it = headers->find(path_header);
+ if (it != (*headers).end())
path = it->second;
std::string url = scheme + "://" + host_port + path;
return GURL(url);

Powered by Google App Engine
This is Rietveld 408576698