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

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

Issue 6339012: More net/ method ordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More done while waiting for previous patch to clear Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_network_layer.cc ('k') | net/http/mock_gssapi_library_posix.h » ('j') | 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) 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (it == headers_.end()) 70 if (it == headers_.end())
71 return false; 71 return false;
72 out->assign(it->value); 72 out->assign(it->value);
73 return true; 73 return true;
74 } 74 }
75 75
76 void HttpRequestHeaders::Clear() { 76 void HttpRequestHeaders::Clear() {
77 headers_.clear(); 77 headers_.clear();
78 } 78 }
79 79
80 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key,
81 const base::StringPiece& value) {
82 HeaderVector::iterator it = FindHeader(key);
83 if (it == headers_.end())
84 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string()));
85 }
86
87 void HttpRequestHeaders::SetHeader(const base::StringPiece& key, 80 void HttpRequestHeaders::SetHeader(const base::StringPiece& key,
88 const base::StringPiece& value) { 81 const base::StringPiece& value) {
89 HeaderVector::iterator it = FindHeader(key); 82 HeaderVector::iterator it = FindHeader(key);
90 if (it != headers_.end()) 83 if (it != headers_.end())
91 it->value = value.as_string(); 84 it->value = value.as_string();
92 else 85 else
93 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string())); 86 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string()));
94 } 87 }
95 88
89 void HttpRequestHeaders::SetHeaderIfMissing(const base::StringPiece& key,
90 const base::StringPiece& value) {
91 HeaderVector::iterator it = FindHeader(key);
92 if (it == headers_.end())
93 headers_.push_back(HeaderKeyValuePair(key.as_string(), value.as_string()));
94 }
95
96 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) { 96 void HttpRequestHeaders::RemoveHeader(const base::StringPiece& key) {
97 HeaderVector::iterator it = FindHeader(key); 97 HeaderVector::iterator it = FindHeader(key);
98 if (it != headers_.end()) 98 if (it != headers_.end())
99 headers_.erase(it); 99 headers_.erase(it);
100 } 100 }
101 101
102 void HttpRequestHeaders::AddHeaderFromString( 102 void HttpRequestHeaders::AddHeaderFromString(
103 const base::StringPiece& header_line) { 103 const base::StringPiece& header_line) {
104 DCHECK_EQ(std::string::npos, header_line.find("\r\n")) 104 DCHECK_EQ(std::string::npos, header_line.find("\r\n"))
105 << "\"" << header_line << "\" contains CRLF."; 105 << "\"" << header_line << "\" contains CRLF.";
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 it != headers_.end(); ++it) { 197 it != headers_.end(); ++it) {
198 if (key.length() == it->key.length() && 198 if (key.length() == it->key.length() &&
199 !base::strncasecmp(key.data(), it->key.data(), key.length())) 199 !base::strncasecmp(key.data(), it->key.data(), key.length()))
200 return it; 200 return it;
201 } 201 }
202 202
203 return headers_.end(); 203 return headers_.end();
204 } 204 }
205 205
206 } // namespace net 206 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_layer.cc ('k') | net/http/mock_gssapi_library_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698