bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
EffectiveUrl.h
1// -*- mode: c++; c-basic-offset:4 -*-
2//
3// EffectiveUrl.h
4// This file is part of the BES http package, part of the Hyrax data server.
5
6// Copyright (c) 2020 OPeNDAP, Inc.
7// Author: Nathan Potter <ndp@opendap.org>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25// Authors:
26// ndp Nathan Potter <ndp@opendap.org>
27
28
29#ifndef HYRAX_GIT_EFFECTIVEURL_H
30#define HYRAX_GIT_EFFECTIVEURL_H
31
32#include <chrono>
33
34#include <memory>
35#include <string>
36#include <map>
37#include <utility>
38
39#include "HttpNames.h"
40#include "url_impl.h"
41
42namespace http {
43
48class EffectiveUrl : public url {
49 // inherit constructors. jhrg 12/29/22
50 using url::url;
51
52 // We need order, so we use two vectors instead of a map to hold the header "map"
53 std::vector<std::string> d_response_header_names;
54 std::vector<std::string> d_response_header_values;
55
56public:
57 EffectiveUrl() = default;
58 EffectiveUrl(const EffectiveUrl &src_url) = default;
59
60 EffectiveUrl(const std::string &url_s, bool trusted) : http::url(url_s, trusted) {};
61 EffectiveUrl(const std::string &url_s, const std::vector<std::string> &resp_hdrs, bool trusted = false)
62 : http::url(url_s, trusted) {
63 ingest_response_headers(resp_hdrs);
64 }
65
66 explicit EffectiveUrl(const http::url &src_url) : http::url(src_url) {}
67
68 explicit EffectiveUrl(const std::shared_ptr<http::EffectiveUrl> &source_url)
69 : http::url(source_url),
70 d_response_header_names(source_url->d_response_header_names),
71 d_response_header_values(source_url->d_response_header_values) {}
72 explicit EffectiveUrl(const std::shared_ptr<http::EffectiveUrl> &source_url, bool trusted)
73 : http::url(source_url,trusted),
74 d_response_header_names(source_url->d_response_header_names),
75 d_response_header_values(source_url->d_response_header_values) {}
76
77 ~EffectiveUrl() override = default;
78
79 bool is_expired() override;
80
81 void get_header(const std::string &name, std::string &value, bool &found );
82
83 void ingest_response_headers(const std::vector<std::string> &resp_hdrs);
84
85 std::string dump() override;
86};
87
88} // namespace http
89
90#endif //HYRAX_GIT_EFFECTIVEURL_H
std::string dump() override
A string dump of the instance.
bool is_expired() override
Returns true if URL is reusable, false otherwise.
void get_header(const std::string &name, std::string &value, bool &found)
get the value of the named header
void ingest_response_headers(const std::vector< std::string > &resp_hdrs)
Replaces the existing header names and values with the new response headers.
Parse a URL into the protocol, host, path and query parts.
Definition url_impl.h:44
utility class for the HTTP catalog module
Definition TheBESKeys.h:51