libdap  Updated for version 3.17.2
D4Connect.h
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2013 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #ifndef _d4connect_h
27 #define _d4connect_h
28 
29 #include <string>
30 
31 
32 #define DAP4_CE_QUERY_KEY "dap4.ce"
33 
34 
35 namespace libdap
36 {
37 
38 class HTTPConnect;
39 class DMR;
40 class Response;
41 
42 class D4Connect
43 {
44 private:
45  HTTPConnect *d_http;
46 
47  bool d_local; // Is this a local connection?
48  std::string d_URL; // URL to remote dataset (minus CE)
49  std::string d_UrlQueryString; // CE
50 
51  std::string d_server; // Server implementation information (the XDAP-Server header)
52  std::string d_protocol; // DAP protocol from the server (XDAP)
53 
54  void process_data(DMR &data, Response &rs);
55  void process_dmr(DMR &data, Response &rs);
56 
57  // Use when you cannot use but have a complete response with MIME headers
58  void parse_mime(Response &rs);
59 
60  std::string build_dap4_ce(const std::string requestSuffix, const std::string expr);
61 
62 protected:
64  D4Connect();
65  D4Connect(const D4Connect &);
66  D4Connect &operator=(const D4Connect &);
67 
68 public:
69  D4Connect(const std::string &url, std::string uname = "", std::string password = "");
70 
71  virtual ~D4Connect();
72 
73  bool is_local() const { return d_local; }
74 
75  virtual std::string URL() const { return d_URL; }
76  virtual std::string CE() const { return d_UrlQueryString; }
77 
78  void set_credentials(std::string u, std::string p);
79  void set_accept_deflate(bool deflate);
80  void set_xdap_protocol(int major, int minor);
81 
82  void set_cache_enabled(bool enabled);
83  bool is_cache_enabled();
84 
85  void set_xdap_accept(int major, int minor);
86 
96  std::string get_version() { return d_server; }
97 
101  std::string get_protocol() { return d_protocol; }
102 
103  virtual void request_dmr(DMR &dmr, const std::string expr = "");
104  virtual void request_dap4_data(DMR &dmr, const std::string expr = "");
105 #if 0
106  virtual void request_version();
107 #endif
108 
109  virtual void read_dmr(DMR &dmr, Response &rs);
110  virtual void read_dmr_no_mime(DMR &dmr, Response &rs);
111 
112  virtual void read_data(DMR &data, Response &rs);
113  virtual void read_data_no_mime(DMR &data, Response &rs);
114 
115 
116 
117 
118 };
119 
120 } // namespace libdap
121 
122 #endif // _d4connect_h
void set_credentials(std::string u, std::string p)
Set the credentials for responding to challenges while dereferencing URLs.
Definition: D4Connect.cc:523
std::string get_version()
Definition: D4Connect.h:96
void set_xdap_protocol(int major, int minor)
Definition: D4Connect.cc:543
std::string get_protocol()
Definition: D4Connect.h:101
void set_accept_deflate(bool deflate)
Definition: D4Connect.cc:532
void set_cache_enabled(bool enabled)
Definition: D4Connect.cc:552