blob: 68d1c0952b3cd4e48133608e2413a3b9770ab24f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#ifndef HTTP_TYPES_H
#define HTTP_TYPES_H
namespace isc {
namespace http {
/// @brief HTTP protocol version.
struct HttpVersion {
unsigned major_; ///< Major HTTP version.
unsigned minor_; ///< Minor HTTP version.
/// @brief Constructor.
///
/// @param major Major HTTP version.
/// @param minor Minor HTTP version.
explicit HttpVersion(const unsigned major, const unsigned minor)
: major_(major), minor_(minor) {
}
/// @brief Operator less.
///
/// @param rhs Version to compare to.
bool operator<(const HttpVersion& rhs) const {
return ((major_ < rhs.major_) ||
((major_ == rhs.major_) && (minor_ < rhs.minor_)));
}
/// @brief Operator equal.
///
/// @param rhs Version to compare to.
bool operator==(const HttpVersion& rhs) const {
return ((major_ == rhs.major_) && (minor_ == rhs.minor_));
}
/// @brief Operator not equal.
///
/// @param rhs Version to compare to.
bool operator!=(const HttpVersion& rhs) const {
return (!operator==(rhs));
}
/// @name Methods returning @c HttpVersion object encapsulating typical
/// HTTP version numbers.
//@{
/// @brief HTTP version 1.0.
static const HttpVersion& HTTP_10() {
static HttpVersion ver(1, 0);
return (ver);
};
/// @brief HTTP version 1.1.
static const HttpVersion& HTTP_11() {
static HttpVersion ver(1, 1);
return (ver);
}
/// @brief HTTP version 2.0.
static const HttpVersion& HTTP_20() {
static HttpVersion ver(2, 0);
return (ver);
}
//@}
};
} // end of namespace isc::http
} // end of namespace isc
#endif
|