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

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

Issue 2753453003: Reject unadvertised encodings (Closed)
Patch Set: Fix histo value comments Created 3 years, 8 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 | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_util.cc » ('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) 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 #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 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <set>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/strings/string_piece.h" 17 #include "base/strings/string_piece.h"
17 #include "base/strings/string_tokenizer.h" 18 #include "base/strings/string_tokenizer.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "net/base/net_export.h" 20 #include "net/base/net_export.h"
20 #include "net/http/http_byte_range.h" 21 #include "net/http/http_byte_range.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 224
224 // Gets a vector of common HTTP status codes for histograms of status 225 // Gets a vector of common HTTP status codes for histograms of status
225 // codes. Currently returns everything in the range [100, 600), plus 0 226 // codes. Currently returns everything in the range [100, 600), plus 0
226 // (for invalid responses/status codes). 227 // (for invalid responses/status codes).
227 static std::vector<int> GetStatusCodesForHistogram(); 228 static std::vector<int> GetStatusCodesForHistogram();
228 229
229 // Maps an HTTP status code to one of the status codes in the vector 230 // Maps an HTTP status code to one of the status codes in the vector
230 // returned by GetStatusCodesForHistogram. 231 // returned by GetStatusCodesForHistogram.
231 static int MapStatusCodeForHistogram(int code); 232 static int MapStatusCodeForHistogram(int code);
232 233
234 // Returns true if |accept_encoding| is well-formed. Parsed encodings turned
235 // to lower case, are placed to provided string-set. Resulting set is
236 // augmented to fulfill the RFC 2616 and RFC 7231 recommendations, e.g. if
237 // there is no encodings specified, then {"*"} is returned to denote that
238 // client has to encoding preferences (but it does not imply that the
239 // user agent will be able to correctly process all encodings).
240 static bool ParseAcceptEncoding(const std::string& accept_encoding,
241 std::set<std::string>* allowed_encodings);
242
243 // Returns true if |content_encoding| is well-formed. Parsed encodings turned
244 // to lower case, are placed to provided string-set. See sections 14.11 and
245 // 3.5 of RFC 2616.
246 static bool ParseContentEncoding(const std::string& content_encoding,
247 std::set<std::string>* used_encodings);
248
233 // Used to iterate over the name/value pairs of HTTP headers. To iterate 249 // Used to iterate over the name/value pairs of HTTP headers. To iterate
234 // over the values in a multi-value header, use ValuesIterator. 250 // over the values in a multi-value header, use ValuesIterator.
235 // See AssembleRawHeaders for joining line continuations (this iterator 251 // See AssembleRawHeaders for joining line continuations (this iterator
236 // does not expect any). 252 // does not expect any).
237 class NET_EXPORT HeadersIterator { 253 class NET_EXPORT HeadersIterator {
238 public: 254 public:
239 HeadersIterator(std::string::const_iterator headers_begin, 255 HeadersIterator(std::string::const_iterator headers_begin,
240 std::string::const_iterator headers_end, 256 std::string::const_iterator headers_end,
241 const std::string& line_delimiter); 257 const std::string& line_delimiter);
242 ~HeadersIterator(); 258 ~HeadersIterator();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // True if quotes values are required to be properly quoted; false if 441 // True if quotes values are required to be properly quoted; false if
426 // mismatched quotes and other problems with quoted values should be more 442 // mismatched quotes and other problems with quoted values should be more
427 // or less gracefully treated as valid. 443 // or less gracefully treated as valid.
428 bool strict_quotes_; 444 bool strict_quotes_;
429 }; 445 };
430 }; 446 };
431 447
432 } // namespace net 448 } // namespace net
433 449
434 #endif // NET_HTTP_HTTP_UTIL_H_ 450 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698