diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-13 00:45:27 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-13 00:45:27 +0000 |
commit | 231d5a36e476d013a91ca742bb8a0a2973cfee54 (patch) | |
tree | dc5c60f8fc054503f4971b770196ed89fbfc18c1 /net/http/http_response_headers.h | |
parent | f4f2df8024d7adf583a61b742a32eaa17522f154 (diff) | |
download | chromium_src-231d5a36e476d013a91ca742bb8a0a2973cfee54.zip chromium_src-231d5a36e476d013a91ca742bb8a0a2973cfee54.tar.gz chromium_src-231d5a36e476d013a91ca742bb8a0a2973cfee54.tar.bz2 |
misc. http response status-line changes:
1. check for http 0.9 responses (no status line)
2. allow up to 4 bytes of junk to precede the http version.
3. distinguish between the parsed vs normalized http version (a TODO needed this).
Review URL: http://codereview.chromium.org/1934
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2153 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_response_headers.h')
-rw-r--r-- | net/http/http_response_headers.h | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/net/http/http_response_headers.h b/net/http/http_response_headers.h index 1c9f518..feba262 100644 --- a/net/http/http_response_headers.h +++ b/net/http/http_response_headers.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/hash_tables.h" #include "base/ref_counted.h" +#include "net/http/http_version.h" class Pickle; class Time; @@ -89,6 +90,19 @@ class HttpResponseHeaders : // "HTTP/0.9 200 OK". std::string GetStatusLine() const; + // Get the HTTP version of the normalized status line. + HttpVersion GetHttpVersion() const { + return http_version_; + } + + // Get the HTTP version determined while parsing; or (0,0) if parsing failed + HttpVersion GetParsedHttpVersion() const { + return parsed_http_version_; + } + + // Get the HTTP status text of the normalized status line. + std::string GetStatusText() const; + // Enumerate the "lines" of the response headers. This skips over the status // line. Use GetStatusLine if you are interested in that. Note that this // method returns the un-coalesced response header lines, so if a response @@ -192,10 +206,9 @@ class HttpResponseHeaders : // Tries to extract the "HTTP/X.Y" from a status line formatted like: // HTTP/1.1 200 OK // with line_begin and end pointing at the begin and end of this line. If the - // status line is malformed, we'll guess a version number. - // Output will be a normalized version of this, with a trailing \n. - void ParseVersion(std::string::const_iterator line_begin, - std::string::const_iterator line_end); + // status line is malformed, returns HttpVersion(0,0). + static HttpVersion ParseVersion(std::string::const_iterator line_begin, + std::string::const_iterator line_end); // Tries to extract the status line from a header block, given the first // line of said header block. If the status line is malformed, we'll construct @@ -204,7 +217,8 @@ class HttpResponseHeaders : // with line_begin and end pointing at the begin and end of this line. // Output will be a normalized version of this, with a trailing \n. void ParseStatusLine(std::string::const_iterator line_begin, - std::string::const_iterator line_end); + std::string::const_iterator line_end, + bool has_headers); // Find the header in our list (case-insensitive) starting with parsed_ at // index |from|. Returns string::npos if not found. @@ -258,6 +272,12 @@ class HttpResponseHeaders : // This is the parsed HTTP response code. int response_code_; + // The normalized http version (consistent with what GetStatusLine() returns). + HttpVersion http_version_; + + // The parsed http version number (not normalized). + HttpVersion parsed_http_version_; + DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); }; |