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 // HttpRequestHeaders manages the request headers. | 5 // HttpRequestHeaders manages the request headers. |
6 // It maintains these in a vector of header key/value pairs, thereby maintaining | 6 // It maintains these in a vector of header key/value pairs, thereby maintaining |
7 // the order of the headers. This means that any lookups are linear time | 7 // the order of the headers. This means that any lookups are linear time |
8 // operations. | 8 // operations. |
9 | 9 |
10 #ifndef NET_HTTP_HTTP_REQUEST_HEADERS_H_ | 10 #ifndef NET_HTTP_HTTP_REQUEST_HEADERS_H_ |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 // Same thing as AddHeaderFromString() except that |headers| is a "\r\n" | 126 // Same thing as AddHeaderFromString() except that |headers| is a "\r\n" |
127 // delimited string of header lines. It will split up the string by "\r\n" | 127 // delimited string of header lines. It will split up the string by "\r\n" |
128 // and call AddHeaderFromString() on each. | 128 // and call AddHeaderFromString() on each. |
129 void AddHeadersFromString(const base::StringPiece& headers); | 129 void AddHeadersFromString(const base::StringPiece& headers); |
130 | 130 |
131 // Calls SetHeader() on each header from |other|, maintaining order. | 131 // Calls SetHeader() on each header from |other|, maintaining order. |
132 void MergeFrom(const HttpRequestHeaders& other); | 132 void MergeFrom(const HttpRequestHeaders& other); |
133 | 133 |
134 // Copies from |other| to |this|. | 134 // Copies from |other| to |this|. |
135 void CopyFrom(const HttpRequestHeaders& other) { | 135 void CopyFrom(const HttpRequestHeaders& other) { *this = other; } |
136 *this = other; | |
137 } | |
138 | 136 |
139 void Swap(HttpRequestHeaders* other) { | 137 void Swap(HttpRequestHeaders* other) { headers_.swap(other->headers_); } |
140 headers_.swap(other->headers_); | |
141 } | |
142 | 138 |
143 // Serializes HttpRequestHeaders to a string representation. Joins all the | 139 // Serializes HttpRequestHeaders to a string representation. Joins all the |
144 // header keys and values with ": ", and inserts "\r\n" between each header | 140 // header keys and values with ": ", and inserts "\r\n" between each header |
145 // line, and adds the trailing "\r\n". | 141 // line, and adds the trailing "\r\n". |
146 std::string ToString() const; | 142 std::string ToString() const; |
147 | 143 |
148 // Takes in the request line and returns a Value for use with the NetLog | 144 // Takes in the request line and returns a Value for use with the NetLog |
149 // containing both the request line and all headers fields. | 145 // containing both the request line and all headers fields. |
150 base::Value* NetLogCallback(const std::string* request_line, | 146 base::Value* NetLogCallback(const std::string* request_line, |
151 NetLog::LogLevel log_level) const; | 147 NetLog::LogLevel log_level) const; |
(...skipping 16 matching lines...) Expand all Loading... |
168 // Allow the copy construction and operator= to facilitate copying in | 164 // Allow the copy construction and operator= to facilitate copying in |
169 // HttpRequestHeaders. | 165 // HttpRequestHeaders. |
170 // TODO(willchan): Investigate to see if we can remove the need to copy | 166 // TODO(willchan): Investigate to see if we can remove the need to copy |
171 // HttpRequestHeaders. | 167 // HttpRequestHeaders. |
172 // DISALLOW_COPY_AND_ASSIGN(HttpRequestHeaders); | 168 // DISALLOW_COPY_AND_ASSIGN(HttpRequestHeaders); |
173 }; | 169 }; |
174 | 170 |
175 } // namespace net | 171 } // namespace net |
176 | 172 |
177 #endif // NET_HTTP_HTTP_REQUEST_HEADERS_H_ | 173 #endif // NET_HTTP_HTTP_REQUEST_HEADERS_H_ |
OLD | NEW |