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

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

Issue 92006: Implement a parser that parses the "Range" HTTP header... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_byte_range_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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 <vector>
9
8 #include "base/string_tokenizer.h" 10 #include "base/string_tokenizer.h"
9 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "net/http/http_byte_range.h"
10 13
11 // This is a macro to support extending this string literal at compile time. 14 // This is a macro to support extending this string literal at compile time.
12 // Please excuse me polluting your global namespace! 15 // Please excuse me polluting your global namespace!
13 #define HTTP_LWS " \t" 16 #define HTTP_LWS " \t"
14 17
15 namespace net { 18 namespace net {
16 19
17 class HttpUtil { 20 class HttpUtil {
18 public: 21 public:
19 // Returns the absolute path of the URL, to be used for the http request. 22 // Returns the absolute path of the URL, to be used for the http request.
(...skipping 15 matching lines...) Expand all
35 38
36 // Parses the value of a Content-Type header. The resulting mime_type and 39 // Parses the value of a Content-Type header. The resulting mime_type and
37 // charset values are normalized to lowercase. The mime_type and charset 40 // charset values are normalized to lowercase. The mime_type and charset
38 // output values are only modified if the content_type_str contains a mime 41 // output values are only modified if the content_type_str contains a mime
39 // type and charset value, respectively. 42 // type and charset value, respectively.
40 static void ParseContentType(const std::string& content_type_str, 43 static void ParseContentType(const std::string& content_type_str,
41 std::string* mime_type, 44 std::string* mime_type,
42 std::string* charset, 45 std::string* charset,
43 bool *had_charset); 46 bool *had_charset);
44 47
48 // Scans the headers and look for the first "Range" header in |headers|,
49 // if "Range" exists and the first one of it is well formatted then returns
50 // true, |ranges| will contain a list of valid ranges. If return
51 // value is false then values in |ranges| should not be used. The format of
52 // "Range" header is defined in RFC 2616 Section 14.35.1.
53 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.1
54 static bool ParseRanges(const std::string& headers,
55 std::vector<HttpByteRange>* ranges);
56
45 // Scans the '\r\n'-delimited headers for the given header name. Returns 57 // Scans the '\r\n'-delimited headers for the given header name. Returns
46 // true if a match is found. Input is assumed to be well-formed. 58 // true if a match is found. Input is assumed to be well-formed.
47 // TODO(darin): kill this 59 // TODO(darin): kill this
48 static bool HasHeader(const std::string& headers, const char* name); 60 static bool HasHeader(const std::string& headers, const char* name);
49 61
50 // Strips all header lines from |headers| whose name matches 62 // Strips all header lines from |headers| whose name matches
51 // |headers_to_remove|. |headers_to_remove| is a list of null-terminated 63 // |headers_to_remove|. |headers_to_remove| is a list of null-terminated
52 // lower-case header names, with array length |headers_to_remove_len|. 64 // lower-case header names, with array length |headers_to_remove_len|.
53 // Returns the stripped header lines list, separated by "\r\n". 65 // Returns the stripped header lines list, separated by "\r\n".
54 static std::string StripHeaders(const std::string& headers, 66 static std::string StripHeaders(const std::string& headers,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 private: 221 private:
210 StringTokenizer values_; 222 StringTokenizer values_;
211 std::string::const_iterator value_begin_; 223 std::string::const_iterator value_begin_;
212 std::string::const_iterator value_end_; 224 std::string::const_iterator value_end_;
213 }; 225 };
214 }; 226 };
215 227
216 } // namespace net 228 } // namespace net
217 229
218 #endif // NET_HTTP_HTTP_UTIL_H_ 230 #endif // NET_HTTP_HTTP_UTIL_H_
OLDNEW
« no previous file with comments | « net/http/http_byte_range_unittest.cc ('k') | net/http/http_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698