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 2753453003: Reject unadvertised encodings (Closed)
Patch Set: Extracted code for UMA reporting Created 3 years, 9 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
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 (sections 14.3 and 3.9) recommendations.
237 static bool ParseAcceptEncoding(const std::string& accept_encoding,
238 std::set<std::string>* allowed_encodings);
239
240 // Returns true if |content_encoding| is well-formed. Parsed encodings turned
241 // to lower case, are placed to provided string-set. See sections 14.11 and
242 // 3.5 of RFC 2616.
243 static bool ParseContentEncoding(const std::string& content_encoding,
244 std::set<std::string>* used_encodings);
245
233 // Used to iterate over the name/value pairs of HTTP headers. To iterate 246 // Used to iterate over the name/value pairs of HTTP headers. To iterate
234 // over the values in a multi-value header, use ValuesIterator. 247 // over the values in a multi-value header, use ValuesIterator.
235 // See AssembleRawHeaders for joining line continuations (this iterator 248 // See AssembleRawHeaders for joining line continuations (this iterator
236 // does not expect any). 249 // does not expect any).
237 class NET_EXPORT HeadersIterator { 250 class NET_EXPORT HeadersIterator {
238 public: 251 public:
239 HeadersIterator(std::string::const_iterator headers_begin, 252 HeadersIterator(std::string::const_iterator headers_begin,
240 std::string::const_iterator headers_end, 253 std::string::const_iterator headers_end,
241 const std::string& line_delimiter); 254 const std::string& line_delimiter);
242 ~HeadersIterator(); 255 ~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 438 // True if quotes values are required to be properly quoted; false if
426 // mismatched quotes and other problems with quoted values should be more 439 // mismatched quotes and other problems with quoted values should be more
427 // or less gracefully treated as valid. 440 // or less gracefully treated as valid.
428 bool strict_quotes_; 441 bool strict_quotes_;
429 }; 442 };
430 }; 443 };
431 444
432 } // namespace net 445 } // namespace net
433 446
434 #endif // NET_HTTP_HTTP_UTIL_H_ 447 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698