| 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 = 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 if (protocol_version < SPDY3) { |
| 118 (*headers)["version"] = kHttpProtocolVersion; | 118 (*headers)["version"] = kHttpProtocolVersion; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 148 std::string::const_iterator after_version = | 148 std::string::const_iterator after_version = |
| 149 std::find(status_line.begin(), status_line.end(), ' '); | 149 std::find(status_line.begin(), status_line.end(), ' '); |
| 150 if (protocol_version < SPDY4) { | 150 if (protocol_version < SPDY4) { |
| 151 (*headers)[version_key] = std::string(status_line.begin(), after_version); | 151 (*headers)[version_key] = std::string(status_line.begin(), after_version); |
| 152 } | 152 } |
| 153 (*headers)[status_key] = std::string(after_version + 1, status_line.end()); | 153 (*headers)[status_key] = std::string(after_version + 1, status_line.end()); |
| 154 | 154 |
| 155 void* iter = NULL; | 155 void* iter = NULL; |
| 156 std::string raw_name, value; | 156 std::string raw_name, value; |
| 157 while (response_headers.EnumerateHeaderLines(&iter, &raw_name, &value)) { | 157 while (response_headers.EnumerateHeaderLines(&iter, &raw_name, &value)) { |
| 158 std::string name = StringToLowerASCII(raw_name); | 158 std::string name = base::StringToLowerASCII(raw_name); |
| 159 AddSpdyHeader(name, value, headers); | 159 AddSpdyHeader(name, value, headers); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 COMPILE_ASSERT(HIGHEST - LOWEST < 4 && | 164 COMPILE_ASSERT(HIGHEST - LOWEST < 4 && |
| 165 HIGHEST - MINIMUM_PRIORITY < 5, | 165 HIGHEST - MINIMUM_PRIORITY < 5, |
| 166 request_priority_incompatible_with_spdy); | 166 request_priority_incompatible_with_spdy); |
| 167 | 167 |
| 168 SpdyPriority ConvertRequestPriorityToSpdyPriority( | 168 SpdyPriority ConvertRequestPriorityToSpdyPriority( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 if (it != headers.end()) | 225 if (it != headers.end()) |
| 226 path = it->second; | 226 path = it->second; |
| 227 | 227 |
| 228 std::string url = (scheme.empty() || host_port.empty() || path.empty()) | 228 std::string url = (scheme.empty() || host_port.empty() || path.empty()) |
| 229 ? std::string() | 229 ? std::string() |
| 230 : scheme + "://" + host_port + path; | 230 : scheme + "://" + host_port + path; |
| 231 return GURL(url); | 231 return GURL(url); |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace net | 234 } // namespace net |
| OLD | NEW |