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_version.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_version.h')
-rw-r--r-- | net/http/http_version.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/net/http/http_version.h b/net/http/http_version.h new file mode 100644 index 0000000..9f4cfba --- /dev/null +++ b/net/http/http_version.h @@ -0,0 +1,59 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NET_HTTP_VERSION_H_ +#define NET_HTTP_VERSION_H_ + +#include "base/basictypes.h" + +namespace net { + +// Wrapper for an HTTP (major,minor) version pair. +class HttpVersion { + private: + uint32 value; // Packed as <major>:<minor> + + public: + // Default constructor (major=0, minor=0). + HttpVersion() : value(0) { } + + // Build from unsigned major/minor pair. + HttpVersion(uint16 major, uint16 minor) : value(major << 16 | minor) { } + + // Major version number. + uint16 major() const { + return value >> 16; + } + + // Minor version number. + uint16 minor() const { + return value & 0xffff; + } + + // Overloaded operators: + + bool operator==(const HttpVersion& v) const { + return value == v.value; + } + bool operator!=(const HttpVersion& v) const { + return value != v.value; + } + bool operator>(const HttpVersion& v) const { + return value > v.value; + } + bool operator>=(const HttpVersion& v) const { + return value >= v.value; + } + bool operator<(const HttpVersion& v) const { + return value < v.value; + } + bool operator<=(const HttpVersion& v) const { + return value <= v.value; + } +}; + +} // namespace net + +#endif // NET_HTTP_VERSION_H_ + |