Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: net/http/http_request_headers.cc

Issue 2268423004: Revert of Make calling SetHeader() with invalid value fatal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return true; 83 return true;
84 } 84 }
85 85
86 void HttpRequestHeaders::Clear() { 86 void HttpRequestHeaders::Clear() {
87 headers_.clear(); 87 headers_.clear();
88 } 88 }
89 89
90 void HttpRequestHeaders::SetHeader(const base::StringPiece& key, 90 void HttpRequestHeaders::SetHeader(const base::StringPiece& key,
91 const base::StringPiece& value) { 91 const base::StringPiece& value) {
92 DCHECK(HttpUtil::IsValidHeaderName(key.as_string())); 92 DCHECK(HttpUtil::IsValidHeaderName(key.as_string()));
93 // TODO(ricea): Revert this. See crbug.com/627398. 93 DCHECK(HttpUtil::IsValidHeaderValue(value.as_string()));
94 CHECK(HttpUtil::IsValidHeaderValue(value.as_string()));
95 HeaderVector::iterator it = FindHeader(key); 94 HeaderVector::iterator it = FindHeader(key);
96 if (it != headers_.end()) 95 if (it != headers_.end())
97 it->value.assign(value.data(), value.size()); 96 it->value.assign(value.data(), value.size());
98 else 97 else
99 headers_.push_back(HeaderKeyValuePair(key, value)); 98 headers_.push_back(HeaderKeyValuePair(key, value));
100 } 99 }
101 100
102 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key, 101 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key,
103 const base::StringPiece& value) { 102 const base::StringPiece& value) {
104 DCHECK(HttpUtil::IsValidHeaderName(key.as_string())); 103 DCHECK(HttpUtil::IsValidHeaderName(key.as_string()));
105 // TODO(ricea): Revert this. See crbug.com/627398. 104 DCHECK(HttpUtil::IsValidHeaderValue(value.as_string()));
106 CHECK(HttpUtil::IsValidHeaderValue(value.as_string()));
107 HeaderVector::iterator it = FindHeader(key); 105 HeaderVector::iterator it = FindHeader(key);
108 if (it == headers_.end()) 106 if (it == headers_.end())
109 headers_.push_back(HeaderKeyValuePair(key, value)); 107 headers_.push_back(HeaderKeyValuePair(key, value));
110 } 108 }
111 109
112 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) { 110 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) {
113 HeaderVector::iterator it = FindHeader(key); 111 HeaderVector::iterator it = FindHeader(key);
114 if (it != headers_.end()) 112 if (it != headers_.end())
115 headers_.erase(it); 113 headers_.erase(it);
116 } 114 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 for (HeaderVector::const_iterator it = headers_.begin(); 251 for (HeaderVector::const_iterator it = headers_.begin();
254 it != headers_.end(); ++it) { 252 it != headers_.end(); ++it) {
255 if (base::EqualsCaseInsensitiveASCII(key, it->key)) 253 if (base::EqualsCaseInsensitiveASCII(key, it->key))
256 return it; 254 return it;
257 } 255 }
258 256
259 return headers_.end(); 257 return headers_.end();
260 } 258 }
261 259
262 } // namespace net 260 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698