bes  Updated for version 3.20.8
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 <string>
33 #include <map>
34 
35 #include "url_impl.h"
36 
37 namespace http {
38 
43  class EffectiveUrl : public url {
44  private:
45 
46  // We need order so we use two vectors instead of a map to hold the header "map"
47  std::vector<std::string> d_response_header_names;
48  std::vector<std::string> d_response_header_values;
49 
50  // Raw headers
51  std::vector<std::string> d_resp_hdr_lines;
52 
53  public:
54 
55  explicit EffectiveUrl(const std::string &url_s, const std::vector<std::string> &resp_hdrs) : http::url(url_s) {
56  ingest_response_headers(resp_hdrs);
57  };
58 
59  explicit EffectiveUrl(const std::string &url_s) : http::url(url_s), d_response_header_names(), d_response_header_values() {};
60  explicit EffectiveUrl() : http::url(""), d_response_header_names(), d_response_header_values() {};
61 
62  virtual ~EffectiveUrl(){ }
63 
64  bool is_expired() override;
65 
66  void get_header(const std::string &name, std::string &value, bool &found );
67 
68  void ingest_response_headers(const std::vector<std::string> &resp_hdrs);
69 
70  void url(std::string url){
71  parse(url);
72  }
73 
74  std::string dump() override;
75  };
76 } // namespace http
77 
78 #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.
Definition: EffectiveUrl.cc:67
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)
Ingests the passed response hedaers.
void parse(const std::string &source_url)
Definition: url_impl.cc:145
utility class for the HTTP catalog module
Definition: EffectiveUrl.cc:58