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

Side by Side Diff: net/spdy/spdy_http_utils.cc

Issue 1257623004: Send appropriate pseudo-headers in HTTP/2 CONNECT request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/spdy/spdy_http_utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_http_utils.h" 5 #include "net/spdy/spdy_http_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 while (it.GetNext()) { 107 while (it.GetNext()) {
108 std::string name = base::StringToLowerASCII(it.name()); 108 std::string name = base::StringToLowerASCII(it.name());
109 if (name == "connection" || name == "proxy-connection" || 109 if (name == "connection" || name == "proxy-connection" ||
110 name == "transfer-encoding" || name == "host") { 110 name == "transfer-encoding" || name == "host") {
111 continue; 111 continue;
112 } 112 }
113 AddSpdyHeader(name, it.value(), headers); 113 AddSpdyHeader(name, it.value(), headers);
114 } 114 }
115 static const char kHttpProtocolVersion[] = "HTTP/1.1"; 115 static const char kHttpProtocolVersion[] = "HTTP/1.1";
116 116
117 if (protocol_version < SPDY3) { 117 switch (protocol_version) {
118 // TODO(bcn): Remove this code now that SPDY/2 is deprecated. 118 case SPDY2:
119 (*headers)["version"] = kHttpProtocolVersion; 119 // TODO(bnc): Remove this code now that SPDY/2 is deprecated.
120 (*headers)["method"] = info.method; 120 (*headers)["version"] = kHttpProtocolVersion;
121 (*headers)["host"] = GetHostAndOptionalPort(info.url); 121 (*headers)["method"] = info.method;
122 if (info.method == "CONNECT") { 122 (*headers)["host"] = GetHostAndOptionalPort(info.url);
123 (*headers)["url"] = GetHostAndPort(info.url); 123 if (info.method == "CONNECT") {
124 } else { 124 (*headers)["url"] = GetHostAndPort(info.url);
125 (*headers)["scheme"] = info.url.scheme(); 125 } else {
126 (*headers)["url"] = direct ? info.url.PathForRequest() 126 (*headers)["scheme"] = info.url.scheme();
127 : HttpUtil::SpecForRequest(info.url); 127 (*headers)["url"] = direct ? info.url.PathForRequest()
128 } 128 : HttpUtil::SpecForRequest(info.url);
129 } else { 129 }
130 if (protocol_version < HTTP2) { 130 break;
131 case SPDY3:
131 (*headers)[":version"] = kHttpProtocolVersion; 132 (*headers)[":version"] = kHttpProtocolVersion;
132 (*headers)[":host"] = GetHostAndOptionalPort(info.url); 133 (*headers)[":host"] = GetHostAndOptionalPort(info.url);
133 } else { 134 (*headers)[":method"] = info.method;
134 (*headers)[":authority"] = GetHostAndOptionalPort(info.url); 135 if (info.method == "CONNECT") {
135 } 136 (*headers)[":path"] = GetHostAndPort(info.url);
136 (*headers)[":method"] = info.method; 137 } else {
137 if (info.method == "CONNECT") { 138 (*headers)[":scheme"] = info.url.scheme();
138 // TODO(bnc): https://crbug.com/433784 139 (*headers)[":path"] = info.url.PathForRequest();
139 (*headers)[":path"] = GetHostAndPort(info.url); 140 }
140 } else { 141 break;
141 (*headers)[":scheme"] = info.url.scheme(); 142 case HTTP2:
142 (*headers)[":path"] = info.url.PathForRequest(); 143 (*headers)[":method"] = info.method;
143 } 144 if (info.method == "CONNECT") {
145 (*headers)[":authority"] = GetHostAndPort(info.url);
146 } else {
147 (*headers)[":authority"] = GetHostAndOptionalPort(info.url);
148 (*headers)[":scheme"] = info.url.scheme();
149 (*headers)[":path"] = info.url.PathForRequest();
150 }
151 break;
152 default:
153 NOTREACHED();
144 } 154 }
145 } 155 }
146 156
147 void CreateSpdyHeadersFromHttpResponse( 157 void CreateSpdyHeadersFromHttpResponse(
148 const HttpResponseHeaders& response_headers, 158 const HttpResponseHeaders& response_headers,
149 SpdyMajorVersion protocol_version, 159 SpdyMajorVersion protocol_version,
150 SpdyHeaderBlock* headers) { 160 SpdyHeaderBlock* headers) {
151 std::string status_key = (protocol_version >= SPDY3) ? ":status" : "status"; 161 std::string status_key = (protocol_version >= SPDY3) ? ":status" : "status";
152 std::string version_key = 162 std::string version_key =
153 (protocol_version >= SPDY3) ? ":version" : "version"; 163 (protocol_version >= SPDY3) ? ":version" : "version";
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 url.append(it->second); 214 url.append(it->second);
205 215
206 it = headers.find(":path"); 216 it = headers.find(":path");
207 if (it == headers.end()) 217 if (it == headers.end())
208 return GURL(); 218 return GURL();
209 url.append(it->second); 219 url.append(it->second);
210 return GURL(url); 220 return GURL(url);
211 } 221 }
212 222
213 } // namespace net 223 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/spdy/spdy_http_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698