OLD | NEW |
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 if (protocol_version < SPDY3) { | 117 if (protocol_version < SPDY3) { |
118 // TODO(bcn): Remove this code now that SPDY/2 is deprecated. | 118 // TODO(bcn): Remove this code now that SPDY/2 is deprecated. |
119 (*headers)["version"] = kHttpProtocolVersion; | 119 (*headers)["version"] = kHttpProtocolVersion; |
120 (*headers)["method"] = info.method; | 120 (*headers)["method"] = info.method; |
121 (*headers)["host"] = GetHostAndOptionalPort(info.url); | 121 (*headers)["host"] = GetHostAndOptionalPort(info.url); |
122 if (info.method == "CONNECT") { | 122 if (info.method == "CONNECT") { |
123 (*headers)["url"] = GetHostAndPort(info.url); | 123 (*headers)["url"] = GetHostAndPort(info.url); |
124 } else { | 124 } else { |
125 (*headers)["scheme"] = info.url.scheme(); | 125 (*headers)["scheme"] = info.url.scheme(); |
126 (*headers)["url"] = direct ? HttpUtil::PathForRequest(info.url) | 126 (*headers)["url"] = direct ? info.url.PathForRequest() |
127 : HttpUtil::SpecForRequest(info.url); | 127 : HttpUtil::SpecForRequest(info.url); |
128 } | 128 } |
129 } else { | 129 } else { |
130 if (protocol_version < SPDY4) { | 130 if (protocol_version < SPDY4) { |
131 (*headers)[":version"] = kHttpProtocolVersion; | 131 (*headers)[":version"] = kHttpProtocolVersion; |
132 (*headers)[":host"] = GetHostAndOptionalPort(info.url); | 132 (*headers)[":host"] = GetHostAndOptionalPort(info.url); |
133 } else { | 133 } else { |
134 (*headers)[":authority"] = GetHostAndOptionalPort(info.url); | 134 (*headers)[":authority"] = GetHostAndOptionalPort(info.url); |
135 } | 135 } |
136 (*headers)[":method"] = info.method; | 136 (*headers)[":method"] = info.method; |
137 if (info.method == "CONNECT") { | 137 if (info.method == "CONNECT") { |
138 // TODO(bnc): https://crbug.com/433784 | 138 // TODO(bnc): https://crbug.com/433784 |
139 (*headers)[":path"] = GetHostAndPort(info.url); | 139 (*headers)[":path"] = GetHostAndPort(info.url); |
140 } else { | 140 } else { |
141 (*headers)[":scheme"] = info.url.scheme(); | 141 (*headers)[":scheme"] = info.url.scheme(); |
142 (*headers)[":path"] = HttpUtil::PathForRequest(info.url); | 142 (*headers)[":path"] = info.url.PathForRequest(); |
143 } | 143 } |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 void CreateSpdyHeadersFromHttpResponse( | 147 void CreateSpdyHeadersFromHttpResponse( |
148 const HttpResponseHeaders& response_headers, | 148 const HttpResponseHeaders& response_headers, |
149 SpdyMajorVersion protocol_version, | 149 SpdyMajorVersion protocol_version, |
150 SpdyHeaderBlock* headers) { | 150 SpdyHeaderBlock* headers) { |
151 std::string status_key = (protocol_version >= SPDY3) ? ":status" : "status"; | 151 std::string status_key = (protocol_version >= SPDY3) ? ":status" : "status"; |
152 std::string version_key = | 152 std::string version_key = |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 url.append(it->second); | 204 url.append(it->second); |
205 | 205 |
206 it = headers.find(":path"); | 206 it = headers.find(":path"); |
207 if (it == headers.end()) | 207 if (it == headers.end()) |
208 return GURL(); | 208 return GURL(); |
209 url.append(it->second); | 209 url.append(it->second); |
210 return GURL(url); | 210 return GURL(url); |
211 } | 211 } |
212 | 212 |
213 } // namespace net | 213 } // namespace net |
OLD | NEW |