OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/http/http_request_headers.h" | 5 #include "net/http/http_request_headers.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_split.h" |
8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
9 #include "net/http/http_util.h" | 10 #include "net/http/http_util.h" |
10 | 11 |
11 namespace net { | 12 namespace net { |
12 | 13 |
13 const char HttpRequestHeaders::kGetMethod[] = "GET"; | 14 const char HttpRequestHeaders::kGetMethod[] = "GET"; |
14 const char HttpRequestHeaders::kAcceptCharset[] = "Accept-Charset"; | 15 const char HttpRequestHeaders::kAcceptCharset[] = "Accept-Charset"; |
15 const char HttpRequestHeaders::kAcceptEncoding[] = "Accept-Encoding"; | 16 const char HttpRequestHeaders::kAcceptEncoding[] = "Accept-Encoding"; |
16 const char HttpRequestHeaders::kAcceptLanguage[] = "Accept-Language"; | 17 const char HttpRequestHeaders::kAcceptLanguage[] = "Accept-Language"; |
17 const char HttpRequestHeaders::kCacheControl[] = "Cache-Control"; | 18 const char HttpRequestHeaders::kCacheControl[] = "Cache-Control"; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } else { | 133 } else { |
133 NOTREACHED(); | 134 NOTREACHED(); |
134 } | 135 } |
135 } | 136 } |
136 | 137 |
137 void HttpRequestHeaders::AddHeadersFromString( | 138 void HttpRequestHeaders::AddHeadersFromString( |
138 const base::StringPiece& headers) { | 139 const base::StringPiece& headers) { |
139 // TODO(willchan): Consider adding more StringPiece support in string_util.h | 140 // TODO(willchan): Consider adding more StringPiece support in string_util.h |
140 // to eliminate copies. | 141 // to eliminate copies. |
141 std::vector<std::string> header_line_vector; | 142 std::vector<std::string> header_line_vector; |
142 SplitStringUsingSubstr(headers.as_string(), "\r\n", &header_line_vector); | 143 base::SplitStringUsingSubstr(headers.as_string(), "\r\n", |
| 144 &header_line_vector); |
143 for (std::vector<std::string>::const_iterator it = header_line_vector.begin(); | 145 for (std::vector<std::string>::const_iterator it = header_line_vector.begin(); |
144 it != header_line_vector.end(); ++it) { | 146 it != header_line_vector.end(); ++it) { |
145 if (!it->empty()) | 147 if (!it->empty()) |
146 AddHeaderFromString(*it); | 148 AddHeaderFromString(*it); |
147 } | 149 } |
148 } | 150 } |
149 | 151 |
150 void HttpRequestHeaders::MergeFrom(const HttpRequestHeaders& other) { | 152 void HttpRequestHeaders::MergeFrom(const HttpRequestHeaders& other) { |
151 for (HeaderVector::const_iterator it = other.headers_.begin(); | 153 for (HeaderVector::const_iterator it = other.headers_.begin(); |
152 it != other.headers_.end(); ++it ) { | 154 it != other.headers_.end(); ++it ) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 it != headers_.end(); ++it) { | 187 it != headers_.end(); ++it) { |
186 if (key.length() == it->key.length() && | 188 if (key.length() == it->key.length() && |
187 !base::strncasecmp(key.data(), it->key.data(), key.length())) | 189 !base::strncasecmp(key.data(), it->key.data(), key.length())) |
188 return it; | 190 return it; |
189 } | 191 } |
190 | 192 |
191 return headers_.end(); | 193 return headers_.end(); |
192 } | 194 } |
193 | 195 |
194 } // namespace net | 196 } // namespace net |
OLD | NEW |