Chromium Code Reviews| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 if (it == headers_.end()) | 69 if (it == headers_.end()) |
| 70 return false; | 70 return false; |
| 71 out->assign(it->value); | 71 out->assign(it->value); |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void HttpRequestHeaders::Clear() { | 75 void HttpRequestHeaders::Clear() { |
| 76 headers_.clear(); | 76 headers_.clear(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key, | |
| 80 const base::StringPiece& value) { | |
| 81 HeaderVector::iterator it = FindHeader(key); | |
|
willchan no longer on Chromium
2010/12/24 20:38:21
It's probably better just to replace these two lin
| |
| 82 if (it == headers_.end()) | |
| 83 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string())); | |
| 84 } | |
| 85 | |
| 79 void HttpRequestHeaders::SetHeader(const base::StringPiece& key, | 86 void HttpRequestHeaders::SetHeader(const base::StringPiece& key, |
| 80 const base::StringPiece& value) { | 87 const base::StringPiece& value) { |
| 81 HeaderVector::iterator it = FindHeader(key); | 88 HeaderVector::iterator it = FindHeader(key); |
| 82 if (it != headers_.end()) | 89 if (it != headers_.end()) |
| 83 it->value = value.as_string(); | 90 it->value = value.as_string(); |
| 84 else | 91 else |
| 85 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string())); | 92 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string())); |
| 86 } | 93 } |
| 87 | 94 |
| 88 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) { | 95 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 it != headers_.end(); ++it) { | 196 it != headers_.end(); ++it) { |
| 190 if (key.length() == it->key.length() && | 197 if (key.length() == it->key.length() && |
| 191 !base::strncasecmp(key.data(), it->key.data(), key.length())) | 198 !base::strncasecmp(key.data(), it->key.data(), key.length())) |
| 192 return it; | 199 return it; |
| 193 } | 200 } |
| 194 | 201 |
| 195 return headers_.end(); | 202 return headers_.end(); |
| 196 } | 203 } |
| 197 | 204 |
| 198 } // namespace net | 205 } // namespace net |
| OLD | NEW |