Kea 2.7.6
http_header.cc
Go to the documentation of this file.
1// Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
10#include <http/http_header.h>
11#include <util/str.h>
12#include <boost/lexical_cast.hpp>
13
14namespace isc {
15namespace http {
16
17HttpHeader::HttpHeader(const std::string& header_name,
18 const std::string& header_value)
19 : header_name_(header_name), header_value_(header_value) {
20}
21
22uint64_t
24 try {
25 return (boost::lexical_cast<uint64_t>(header_value_));
26
27 } catch (const boost::bad_lexical_cast& ex) {
28 isc_throw(BadValue, header_name_ << " HTTP header value "
29 << header_value_ << " is not a valid number");
30 }
31}
32
33std::string
35 std::string ln = header_name_;
37 return (ln);
38}
39
40std::string
42 std::string lc = header_value_;
44 return (lc);
45}
46
47bool
48HttpHeader::isValueEqual(const std::string& v) const {
49 std::string lcv = v;
51 return (lcv == getLowerCaseValue());
52}
53
54
55} // end of namespace isc::http
56} // end of namespace isc
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
HttpHeader(const std::string &header_name, const std::string &header_value="")
Constructor.
uint64_t getUint64Value() const
Returns header value as unsigned integer.
std::string getLowerCaseName() const
Returns lower case header name.
std::string getLowerCaseValue() const
Returns lower case header value.
bool isValueEqual(const std::string &v) const
Case insensitive comparison of header value.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void lowercase(string &text)
Convert string to lowercase.
Definition str.cc:134
Defines the logger used by the top-level component of kea-lfc.