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

Side by Side Diff: net/http/http_util.h

Issue 7529043: Rename NET_API to NET_EXPORT, and rename NET_TEST to NET_EXPORT_PRIVATE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef NET_HTTP_HTTP_UTIL_H_ 5 #ifndef NET_HTTP_HTTP_UTIL_H_
6 #define NET_HTTP_HTTP_UTIL_H_ 6 #define NET_HTTP_HTTP_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/string_tokenizer.h" 13 #include "base/string_tokenizer.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "net/base/net_api.h" 15 #include "net/base/net_export.h"
16 #include "net/http/http_byte_range.h" 16 #include "net/http/http_byte_range.h"
17 17
18 // This is a macro to support extending this string literal at compile time. 18 // This is a macro to support extending this string literal at compile time.
19 // Please excuse me polluting your global namespace! 19 // Please excuse me polluting your global namespace!
20 #define HTTP_LWS " \t" 20 #define HTTP_LWS " \t"
21 21
22 namespace net { 22 namespace net {
23 23
24 class UploadDataStream; 24 class UploadDataStream;
25 25
26 class NET_API HttpUtil { 26 class NET_EXPORT HttpUtil {
27 public: 27 public:
28 // Returns the absolute path of the URL, to be used for the http request. 28 // Returns the absolute path of the URL, to be used for the http request.
29 // The absolute path starts with a '/' and may contain a query. 29 // The absolute path starts with a '/' and may contain a query.
30 static std::string PathForRequest(const GURL& url); 30 static std::string PathForRequest(const GURL& url);
31 31
32 // Returns the absolute URL, to be used for the http request. This url is 32 // Returns the absolute URL, to be used for the http request. This url is
33 // made up of the protocol, host, [port], path, [query]. Everything else 33 // made up of the protocol, host, [port], path, [query]. Everything else
34 // is stripped (username, password, reference). 34 // is stripped (username, password, reference).
35 static std::string SpecForRequest(const GURL& url); 35 static std::string SpecForRequest(const GURL& url);
36 36
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // Helper. If |*headers| already contains |header_name| do nothing, 164 // Helper. If |*headers| already contains |header_name| do nothing,
165 // otherwise add <header_name> ": " <header_value> to the end of the list. 165 // otherwise add <header_name> ": " <header_value> to the end of the list.
166 static void AppendHeaderIfMissing(const char* header_name, 166 static void AppendHeaderIfMissing(const char* header_name,
167 const std::string& header_value, 167 const std::string& header_value,
168 std::string* headers); 168 std::string* headers);
169 169
170 // Used to iterate over the name/value pairs of HTTP headers. To iterate 170 // Used to iterate over the name/value pairs of HTTP headers. To iterate
171 // over the values in a multi-value header, use ValuesIterator. 171 // over the values in a multi-value header, use ValuesIterator.
172 // See AssembleRawHeaders for joining line continuations (this iterator 172 // See AssembleRawHeaders for joining line continuations (this iterator
173 // does not expect any). 173 // does not expect any).
174 class NET_API HeadersIterator { 174 class NET_EXPORT HeadersIterator {
175 public: 175 public:
176 HeadersIterator(std::string::const_iterator headers_begin, 176 HeadersIterator(std::string::const_iterator headers_begin,
177 std::string::const_iterator headers_end, 177 std::string::const_iterator headers_end,
178 const std::string& line_delimiter); 178 const std::string& line_delimiter);
179 ~HeadersIterator(); 179 ~HeadersIterator();
180 180
181 // Advances the iterator to the next header, if any. Returns true if there 181 // Advances the iterator to the next header, if any. Returns true if there
182 // is a next header. Use name* and values* methods to access the resultant 182 // is a next header. Use name* and values* methods to access the resultant
183 // header name and values. 183 // header name and values.
184 bool GetNext(); 184 bool GetNext();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // automatically trimmed from the resulting values. 227 // automatically trimmed from the resulting values.
228 // 228 //
229 // When using this class to iterate over response header values, be aware that 229 // When using this class to iterate over response header values, be aware that
230 // for some headers (e.g., Last-Modified), commas are not used as delimiters. 230 // for some headers (e.g., Last-Modified), commas are not used as delimiters.
231 // This iterator should be avoided for headers like that which are considered 231 // This iterator should be avoided for headers like that which are considered
232 // non-coalescing (see IsNonCoalescingHeader). 232 // non-coalescing (see IsNonCoalescingHeader).
233 // 233 //
234 // This iterator is careful to skip over delimiters found inside an HTTP 234 // This iterator is careful to skip over delimiters found inside an HTTP
235 // quoted string. 235 // quoted string.
236 // 236 //
237 class NET_TEST ValuesIterator { 237 class NET_EXPORT_PRIVATE ValuesIterator {
238 public: 238 public:
239 ValuesIterator(std::string::const_iterator values_begin, 239 ValuesIterator(std::string::const_iterator values_begin,
240 std::string::const_iterator values_end, 240 std::string::const_iterator values_end,
241 char delimiter); 241 char delimiter);
242 ~ValuesIterator(); 242 ~ValuesIterator();
243 243
244 // Advances the iterator to the next value, if any. Returns true if there 244 // Advances the iterator to the next value, if any. Returns true if there
245 // is a next value. Use value* methods to access the resultant value. 245 // is a next value. Use value* methods to access the resultant value.
246 bool GetNext(); 246 bool GetNext();
247 247
(...skipping 13 matching lines...) Expand all
261 std::string::const_iterator value_end_; 261 std::string::const_iterator value_end_;
262 }; 262 };
263 263
264 // Iterates over a delimited sequence of name-value pairs in an HTTP header. 264 // Iterates over a delimited sequence of name-value pairs in an HTTP header.
265 // Each pair consists of a token (the name), an equals sign, and either a 265 // Each pair consists of a token (the name), an equals sign, and either a
266 // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside 266 // token or quoted-string (the value). Arbitrary HTTP LWS is permitted outside
267 // of and between names, values, and delimiters. 267 // of and between names, values, and delimiters.
268 // 268 //
269 // String iterators returned from this class' methods may be invalidated upon 269 // String iterators returned from this class' methods may be invalidated upon
270 // calls to GetNext() or after the NameValuePairsIterator is destroyed. 270 // calls to GetNext() or after the NameValuePairsIterator is destroyed.
271 class NET_API NameValuePairsIterator { 271 class NET_EXPORT NameValuePairsIterator {
272 public: 272 public:
273 NameValuePairsIterator(std::string::const_iterator begin, 273 NameValuePairsIterator(std::string::const_iterator begin,
274 std::string::const_iterator end, 274 std::string::const_iterator end,
275 char delimiter); 275 char delimiter);
276 ~NameValuePairsIterator(); 276 ~NameValuePairsIterator();
277 277
278 // Advances the iterator to the next pair, if any. Returns true if there 278 // Advances the iterator to the next pair, if any. Returns true if there
279 // is a next pair. Use name* and value* methods to access the resultant 279 // is a next pair. Use name* and value* methods to access the resultant
280 // value. 280 // value.
281 bool GetNext(); 281 bool GetNext();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // into the original's unquoted_value_ member. 318 // into the original's unquoted_value_ member.
319 std::string unquoted_value_; 319 std::string unquoted_value_;
320 320
321 bool value_is_quoted_; 321 bool value_is_quoted_;
322 }; 322 };
323 }; 323 };
324 324
325 } // namespace net 325 } // namespace net
326 326
327 #endif // NET_HTTP_HTTP_UTIL_H_ 327 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698