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

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

Issue 2143903002: Make calling SetHeader() with invalid value fatal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 DCHECK(HttpUtil::IsValidHeaderValue(value.as_string())); 93 // TODO(ricea): Revert this. See crbug.com/627398.
94 CHECK(HttpUtil::IsValidHeaderValue(value.as_string()));
94 HeaderVector::iterator it = FindHeader(key); 95 HeaderVector::iterator it = FindHeader(key);
95 if (it != headers_.end()) 96 if (it != headers_.end())
96 it->value.assign(value.data(), value.size()); 97 it->value.assign(value.data(), value.size());
97 else 98 else
98 headers_.push_back(HeaderKeyValuePair(key, value)); 99 headers_.push_back(HeaderKeyValuePair(key, value));
99 } 100 }
100 101
101 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key, 102 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key,
102 const base::StringPiece& value) { 103 const base::StringPiece& value) {
103 DCHECK(HttpUtil::IsValidHeaderName(key.as_string())); 104 DCHECK(HttpUtil::IsValidHeaderName(key.as_string()));
104 DCHECK(HttpUtil::IsValidHeaderValue(value.as_string())); 105 // TODO(ricea): Revert this. See crbug.com/627398.
106 CHECK(HttpUtil::IsValidHeaderValue(value.as_string()));
105 HeaderVector::iterator it = FindHeader(key); 107 HeaderVector::iterator it = FindHeader(key);
106 if (it == headers_.end()) 108 if (it == headers_.end())
107 headers_.push_back(HeaderKeyValuePair(key, value)); 109 headers_.push_back(HeaderKeyValuePair(key, value));
108 } 110 }
109 111
110 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) { 112 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) {
111 HeaderVector::iterator it = FindHeader(key); 113 HeaderVector::iterator it = FindHeader(key);
112 if (it != headers_.end()) 114 if (it != headers_.end())
113 headers_.erase(it); 115 headers_.erase(it);
114 } 116 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 for (HeaderVector::const_iterator it = headers_.begin(); 253 for (HeaderVector::const_iterator it = headers_.begin();
252 it != headers_.end(); ++it) { 254 it != headers_.end(); ++it) {
253 if (base::EqualsCaseInsensitiveASCII(key, it->key)) 255 if (base::EqualsCaseInsensitiveASCII(key, it->key))
254 return it; 256 return it;
255 } 257 }
256 258
257 return headers_.end(); 259 return headers_.end();
258 } 260 }
259 261
260 } // namespace net 262 } // 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