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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info, | 100 void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info, |
101 const HttpRequestHeaders& request_headers, | 101 const HttpRequestHeaders& request_headers, |
102 SpdyMajorVersion protocol_version, | 102 SpdyMajorVersion protocol_version, |
103 bool direct, | 103 bool direct, |
104 SpdyHeaderBlock* headers) { | 104 SpdyHeaderBlock* headers) { |
105 | 105 |
106 HttpRequestHeaders::Iterator it(request_headers); | 106 HttpRequestHeaders::Iterator it(request_headers); |
107 while (it.GetNext()) { | 107 while (it.GetNext()) { |
108 std::string name = base::StringToLowerASCII(it.name()); | 108 std::string name = base::ToLowerASCII(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 switch (protocol_version) { | 117 switch (protocol_version) { |
118 case SPDY2: | 118 case SPDY2: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 std::string::const_iterator after_version = | 166 std::string::const_iterator after_version = |
167 std::find(status_line.begin(), status_line.end(), ' '); | 167 std::find(status_line.begin(), status_line.end(), ' '); |
168 if (protocol_version < HTTP2) { | 168 if (protocol_version < HTTP2) { |
169 (*headers)[version_key] = std::string(status_line.begin(), after_version); | 169 (*headers)[version_key] = std::string(status_line.begin(), after_version); |
170 } | 170 } |
171 (*headers)[status_key] = std::string(after_version + 1, status_line.end()); | 171 (*headers)[status_key] = std::string(after_version + 1, status_line.end()); |
172 | 172 |
173 void* iter = NULL; | 173 void* iter = NULL; |
174 std::string raw_name, value; | 174 std::string raw_name, value; |
175 while (response_headers.EnumerateHeaderLines(&iter, &raw_name, &value)) { | 175 while (response_headers.EnumerateHeaderLines(&iter, &raw_name, &value)) { |
176 std::string name = base::StringToLowerASCII(raw_name); | 176 std::string name = base::ToLowerASCII(raw_name); |
177 AddSpdyHeader(name, value, headers); | 177 AddSpdyHeader(name, value, headers); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 static_assert(HIGHEST - LOWEST < 4 && HIGHEST - MINIMUM_PRIORITY < 5, | 181 static_assert(HIGHEST - LOWEST < 4 && HIGHEST - MINIMUM_PRIORITY < 5, |
182 "request priority incompatible with spdy"); | 182 "request priority incompatible with spdy"); |
183 | 183 |
184 SpdyPriority ConvertRequestPriorityToSpdyPriority( | 184 SpdyPriority ConvertRequestPriorityToSpdyPriority( |
185 const RequestPriority priority, | 185 const RequestPriority priority, |
186 SpdyMajorVersion protocol_version) { | 186 SpdyMajorVersion protocol_version) { |
(...skipping 27 matching lines...) Expand all Loading... |
214 url.append(it->second); | 214 url.append(it->second); |
215 | 215 |
216 it = headers.find(":path"); | 216 it = headers.find(":path"); |
217 if (it == headers.end()) | 217 if (it == headers.end()) |
218 return GURL(); | 218 return GURL(); |
219 url.append(it->second); | 219 url.append(it->second); |
220 return GURL(url); | 220 return GURL(url); |
221 } | 221 } |
222 | 222 |
223 } // namespace net | 223 } // namespace net |
OLD | NEW |