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_split.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/http/http_util.h" | 10 #include "net/http/http_util.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 for (HeaderVector::const_iterator it = other.headers_.begin(); | 153 for (HeaderVector::const_iterator it = other.headers_.begin(); |
154 it != other.headers_.end(); ++it ) { | 154 it != other.headers_.end(); ++it ) { |
155 SetHeader(it->key, it->value); | 155 SetHeader(it->key, it->value); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 std::string HttpRequestHeaders::ToString() const { | 159 std::string HttpRequestHeaders::ToString() const { |
160 std::string output; | 160 std::string output; |
161 for (HeaderVector::const_iterator it = headers_.begin(); | 161 for (HeaderVector::const_iterator it = headers_.begin(); |
162 it != headers_.end(); ++it) { | 162 it != headers_.end(); ++it) { |
163 if (!it->value.empty()) | 163 if (!it->value.empty()) { |
164 StringAppendF(&output, "%s: %s\r\n", it->key.c_str(), it->value.c_str()); | 164 base::StringAppendF(&output, "%s: %s\r\n", |
165 else | 165 it->key.c_str(), it->value.c_str()); |
166 StringAppendF(&output, "%s:\r\n", it->key.c_str()); | 166 } else { |
| 167 base::StringAppendF(&output, "%s:\r\n", it->key.c_str()); |
| 168 } |
167 } | 169 } |
168 output.append("\r\n"); | 170 output.append("\r\n"); |
169 return output; | 171 return output; |
170 } | 172 } |
171 | 173 |
172 HttpRequestHeaders::HeaderVector::iterator | 174 HttpRequestHeaders::HeaderVector::iterator |
173 HttpRequestHeaders::FindHeader(const base::StringPiece& key) { | 175 HttpRequestHeaders::FindHeader(const base::StringPiece& key) { |
174 for (HeaderVector::iterator it = headers_.begin(); | 176 for (HeaderVector::iterator it = headers_.begin(); |
175 it != headers_.end(); ++it) { | 177 it != headers_.end(); ++it) { |
176 if (key.length() == it->key.length() && | 178 if (key.length() == it->key.length() && |
(...skipping 10 matching lines...) Expand all Loading... |
187 it != headers_.end(); ++it) { | 189 it != headers_.end(); ++it) { |
188 if (key.length() == it->key.length() && | 190 if (key.length() == it->key.length() && |
189 !base::strncasecmp(key.data(), it->key.data(), key.length())) | 191 !base::strncasecmp(key.data(), it->key.data(), key.length())) |
190 return it; | 192 return it; |
191 } | 193 } |
192 | 194 |
193 return headers_.end(); | 195 return headers_.end(); |
194 } | 196 } |
195 | 197 |
196 } // namespace net | 198 } // namespace net |
OLD | NEW |