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

Unified Diff: net/spdy/spdy_http_utils.cc

Issue 2141993002: Remove many-many SpdyMajorVersion and NextProto arguments and members. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove OnSynStream() and OnSynReply(). Created 4 years, 5 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
« no previous file with comments | « net/spdy/spdy_http_utils.h ('k') | net/spdy/spdy_http_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_http_utils.cc
diff --git a/net/spdy/spdy_http_utils.cc b/net/spdy/spdy_http_utils.cc
index 573bce18b8f893b1ba15fb0fa8c5dd759ea625db..1213f1ca8c238fb3fba68a1d84e38ad87a57ec39 100644
--- a/net/spdy/spdy_http_utils.cc
+++ b/net/spdy/spdy_http_utils.cc
@@ -39,31 +39,13 @@ void AddSpdyHeader(const std::string& name,
} // namespace
bool SpdyHeadersToHttpResponse(const SpdyHeaderBlock& headers,
- SpdyMajorVersion protocol_version,
HttpResponseInfo* response) {
- std::string status_key = (protocol_version >= SPDY3) ? ":status" : "status";
- std::string version_key =
- (protocol_version >= SPDY3) ? ":version" : "version";
- std::string version;
- std::string status;
-
- // The "status" header is required. "version" is required below HTTP/2.
- SpdyHeaderBlock::const_iterator it;
- it = headers.find(status_key);
+ // The ":status" header is required.
+ SpdyHeaderBlock::const_iterator it = headers.find(":status");
if (it == headers.end())
return false;
- status = it->second.as_string();
-
- if (protocol_version >= HTTP2) {
- version = "HTTP/1.1";
- } else {
- it = headers.find(version_key);
- if (it == headers.end())
- return false;
- version = it->second.as_string();
- }
- std::string raw_headers(version);
- raw_headers.push_back(' ');
+ std::string status = it->second.as_string();
+ std::string raw_headers("HTTP/1.1 ");
raw_headers.append(status);
raw_headers.push_back('\0');
for (it = headers.begin(); it != headers.end(); ++it) {
@@ -103,34 +85,15 @@ bool SpdyHeadersToHttpResponse(const SpdyHeaderBlock& headers,
void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
const HttpRequestHeaders& request_headers,
- SpdyMajorVersion protocol_version,
bool direct,
SpdyHeaderBlock* headers) {
- static const char kHttpProtocolVersion[] = "HTTP/1.1";
- switch (protocol_version) {
- case SPDY3:
- (*headers)[":version"] = kHttpProtocolVersion;
- (*headers)[":method"] = info.method;
- (*headers)[":host"] = GetHostAndOptionalPort(info.url);
- if (info.method == "CONNECT") {
- (*headers)[":path"] = GetHostAndPort(info.url);
- } else {
- (*headers)[":scheme"] = info.url.scheme();
- (*headers)[":path"] = info.url.PathForRequest();
- }
- break;
- case HTTP2:
- (*headers)[":method"] = info.method;
- if (info.method == "CONNECT") {
- (*headers)[":authority"] = GetHostAndPort(info.url);
- } else {
- (*headers)[":authority"] = GetHostAndOptionalPort(info.url);
- (*headers)[":scheme"] = info.url.scheme();
- (*headers)[":path"] = info.url.PathForRequest();
- }
- break;
- default:
- NOTREACHED();
+ (*headers)[":method"] = info.method;
+ if (info.method == "CONNECT") {
+ (*headers)[":authority"] = GetHostAndPort(info.url);
+ } else {
+ (*headers)[":authority"] = GetHostAndOptionalPort(info.url);
+ (*headers)[":scheme"] = info.url.scheme();
+ (*headers)[":path"] = info.url.PathForRequest();
}
HttpRequestHeaders::Iterator it(request_headers);
@@ -147,23 +110,14 @@ void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
void CreateSpdyHeadersFromHttpResponse(
const HttpResponseHeaders& response_headers,
- SpdyMajorVersion protocol_version,
SpdyHeaderBlock* headers) {
- std::string status_key = (protocol_version >= SPDY3) ? ":status" : "status";
- std::string version_key =
- (protocol_version >= SPDY3) ? ":version" : "version";
-
const std::string status_line = response_headers.GetStatusLine();
std::string::const_iterator after_version =
std::find(status_line.begin(), status_line.end(), ' ');
- if (protocol_version < HTTP2) {
- (*headers)[version_key] = std::string(status_line.begin(), after_version);
- }
-
// Get status code only.
std::string::const_iterator after_status =
std::find(after_version + 1, status_line.end(), ' ');
- (*headers)[status_key] = std::string(after_version + 1, after_status);
+ (*headers)[":status"] = std::string(after_version + 1, after_status);
size_t iter = 0;
std::string raw_name, value;
@@ -177,16 +131,14 @@ static_assert(HIGHEST - LOWEST < 4 && HIGHEST - MINIMUM_PRIORITY < 5,
"request priority incompatible with spdy");
SpdyPriority ConvertRequestPriorityToSpdyPriority(
- const RequestPriority priority,
- SpdyMajorVersion protocol_version) {
+ const RequestPriority priority) {
DCHECK_GE(priority, MINIMUM_PRIORITY);
DCHECK_LE(priority, MAXIMUM_PRIORITY);
return static_cast<SpdyPriority>(MAXIMUM_PRIORITY - priority);
}
-NET_EXPORT_PRIVATE RequestPriority ConvertSpdyPriorityToRequestPriority(
- SpdyPriority priority,
- SpdyMajorVersion protocol_version) {
+NET_EXPORT_PRIVATE RequestPriority
+ConvertSpdyPriorityToRequestPriority(SpdyPriority priority) {
// Handle invalid values gracefully.
// Note that SpdyPriority is not an enum, hence the magic constants.
return (priority >= 5) ?
@@ -209,15 +161,14 @@ NET_EXPORT_PRIVATE void ConvertHeaderBlockToHttpRequestHeaders(
}
}
-GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers,
- SpdyMajorVersion protocol_version) {
+GURL GetUrlFromHeaderBlock(const SpdyHeaderBlock& headers) {
SpdyHeaderBlock::const_iterator it = headers.find(":scheme");
if (it == headers.end())
return GURL();
std::string url = it->second.as_string();
url.append("://");
- it = headers.find(protocol_version >= HTTP2 ? ":authority" : ":host");
+ it = headers.find(":authority");
if (it == headers.end())
return GURL();
url.append(it->second.as_string());
« no previous file with comments | « net/spdy/spdy_http_utils.h ('k') | net/spdy/spdy_http_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698