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/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 void HttpRequestHeaders::Clear() { | 80 void HttpRequestHeaders::Clear() { |
81 headers_.clear(); | 81 headers_.clear(); |
82 } | 82 } |
83 | 83 |
84 void HttpRequestHeaders::SetHeader(const base::StringPiece& key, | 84 void HttpRequestHeaders::SetHeader(const base::StringPiece& key, |
85 const base::StringPiece& value) { | 85 const base::StringPiece& value) { |
86 HeaderVector::iterator it = FindHeader(key); | 86 HeaderVector::iterator it = FindHeader(key); |
87 if (it != headers_.end()) | 87 if (it != headers_.end()) |
88 it->value = value.as_string(); | 88 it->value.assign(value.data(), value.size()); |
89 else | 89 else |
90 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string())); | 90 headers_.push_back(HeaderKeyValuePair(key, value)); |
91 } | 91 } |
92 | 92 |
93 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key, | 93 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key, |
94 const base::StringPiece& value) { | 94 const base::StringPiece& value) { |
95 HeaderVector::iterator it = FindHeader(key); | 95 HeaderVector::iterator it = FindHeader(key); |
96 if (it == headers_.end()) | 96 if (it == headers_.end()) |
97 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string())); | 97 headers_.push_back(HeaderKeyValuePair(key, value)); |
98 } | 98 } |
99 | 99 |
100 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) { | 100 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) { |
101 HeaderVector::iterator it = FindHeader(key); | 101 HeaderVector::iterator it = FindHeader(key); |
102 if (it != headers_.end()) | 102 if (it != headers_.end()) |
103 headers_.erase(it); | 103 headers_.erase(it); |
104 } | 104 } |
105 | 105 |
106 void HttpRequestHeaders::AddHeaderFromString( | 106 void HttpRequestHeaders::AddHeaderFromString( |
107 const base::StringPiece& header_line) { | 107 const base::StringPiece& header_line) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 it != headers_.end(); ++it) { | 249 it != headers_.end(); ++it) { |
250 if (key.length() == it->key.length() && | 250 if (key.length() == it->key.length() && |
251 !base::strncasecmp(key.data(), it->key.data(), key.length())) | 251 !base::strncasecmp(key.data(), it->key.data(), key.length())) |
252 return it; | 252 return it; |
253 } | 253 } |
254 | 254 |
255 return headers_.end(); | 255 return headers_.end(); |
256 } | 256 } |
257 | 257 |
258 } // namespace net | 258 } // namespace net |
OLD | NEW |