| 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/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/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 } else if (value_index == header_line.size()) { | 148 } else if (value_index == header_line.size()) { |
| 149 SetHeader(header_key, ""); | 149 SetHeader(header_key, ""); |
| 150 } else { | 150 } else { |
| 151 NOTREACHED(); | 151 NOTREACHED(); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 void HttpRequestHeaders::AddHeadersFromString( | 155 void HttpRequestHeaders::AddHeadersFromString( |
| 156 const base::StringPiece& headers) { | 156 const base::StringPiece& headers) { |
| 157 // TODO(willchan): Consider adding more StringPiece support in string_util.h | 157 for (const base::StringPiece& header : base::SplitStringPieceUsingSubstr( |
| 158 // to eliminate copies. | 158 headers, "\r\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { |
| 159 std::vector<std::string> header_line_vector; | 159 AddHeaderFromString(header); |
| 160 base::SplitStringUsingSubstr(headers.as_string(), "\r\n", | |
| 161 &header_line_vector); | |
| 162 for (std::vector<std::string>::const_iterator it = header_line_vector.begin(); | |
| 163 it != header_line_vector.end(); ++it) { | |
| 164 if (!it->empty()) | |
| 165 AddHeaderFromString(*it); | |
| 166 } | 160 } |
| 167 } | 161 } |
| 168 | 162 |
| 169 void HttpRequestHeaders::MergeFrom(const HttpRequestHeaders& other) { | 163 void HttpRequestHeaders::MergeFrom(const HttpRequestHeaders& other) { |
| 170 for (HeaderVector::const_iterator it = other.headers_.begin(); | 164 for (HeaderVector::const_iterator it = other.headers_.begin(); |
| 171 it != other.headers_.end(); ++it ) { | 165 it != other.headers_.end(); ++it ) { |
| 172 SetHeader(it->key, it->value); | 166 SetHeader(it->key, it->value); |
| 173 } | 167 } |
| 174 } | 168 } |
| 175 | 169 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 for (HeaderVector::const_iterator it = headers_.begin(); | 247 for (HeaderVector::const_iterator it = headers_.begin(); |
| 254 it != headers_.end(); ++it) { | 248 it != headers_.end(); ++it) { |
| 255 if (base::EqualsCaseInsensitiveASCII(key, it->key)) | 249 if (base::EqualsCaseInsensitiveASCII(key, it->key)) |
| 256 return it; | 250 return it; |
| 257 } | 251 } |
| 258 | 252 |
| 259 return headers_.end(); | 253 return headers_.end(); |
| 260 } | 254 } |
| 261 | 255 |
| 262 } // namespace net | 256 } // namespace net |
| OLD | NEW |