$darkmode
Qore HttpClientDataProvider Module Reference 1.1
HttpClientDataProvider.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
26 namespace HttpClientDataProvider {
28 class HttpClientDataProvider : public AbstractDataProvider {
29 
30 public:
32  const ProviderInfo = <DataProviderInfo>{
33  "type": "HttpClientDataProvider",
34  "constructor_options": ConstructorOptions,
35  "supports_children": True,
36  "children_can_support_apis": True,
37  "children_can_support_records": False,
38  "children_can_support_observers": False,
39  };
40 
42  const ConstructorOptions = {
43  "assume_encoding": <DataProviderOptionInfo>{
44  "type": AbstractDataProviderType::get(StringType),
45  "desc": "Assumes the given encoding if the server does not send a `charset` value",
46  },
47  "connect_timeout": <DataProviderOptionInfo>{
48  "type": AbstractDataProviderType::get(IntType),
49  "desc": "The connection timeout to use in milliseconds (default: 45 seconds)",
50  "default_value": 45000,
51  },
52  "error_passthru": <DataProviderOptionInfo>{
53  "type": AbstractDataProviderType::get(BoolType),
54  "desc": "If `True` then HTTP status codes indicating errors will not cause an "
55  "`HTTP-CLIENT-RECEIVE-ERROR` exception to be raised, rather such responses will be "
56  "passed through to the caller like any other response",
57  "default_value": False,
58  },
59  "headers": <DataProviderOptionInfo>{
60  "type": AbstractDataProviderTypeMap."hash",
61  "desc": "headers to add in each outgoing request",
62  },
63  "http_version": <DataProviderOptionInfo>{
64  "type": AbstractDataProviderType::get(StringType),
65  "desc": "HTTP version to use (`1.0` or `1.1`, defaults to `1.1`)",
66  "default_value": "1.1",
67  "allowed_values": (
68  <AllowedValueInfo>{
69  "value": "1.0",
70  "desc": "Use HTTP version \"1.0\"",
71  }, <AllowedValueInfo>{
72  "value": "1.1",
73  "desc": "Use HTTP version \"1.1\" (the default)",
74  },
75  ),
76  },
77  "max_redirects": <DataProviderOptionInfo>{
78  "type": AbstractDataProviderType::get(IntType),
79  "desc": "Maximum redirects to support",
80  },
81  "pre_encoded_urls": <DataProviderOptionInfo>{
82  "type": AbstractDataProviderType::get(BoolType),
83  "desc": "if `true` then all URI paths in URLs are assumed to be already "
84  "[percent encoded](https://en.wikipedia.org/wiki/Percent-encoding); if this flag is set and "
85  "any unencoded characters are sent in a URL with a new request, an exception is raised",
86  "default_value": False,
87  },
88  "proxy": <DataProviderOptionInfo>{
89  "type": AbstractDataProviderType::get(StringType),
90  "desc": "The proxy URL to use",
91  },
92  "redirect_passthru": <DataProviderOptionInfo>{
93  "type": AbstractDataProviderType::get(BoolType),
94  "desc": "if `True` then redirect responses will be passed to the caller instead of processed",
95  "default_value": False,
96  },
97  "ssl_cert_der": <DataProviderOptionInfo>{
98  "type": AbstractDataProviderType::get(BoolType),
99  "desc": "If `True` then the data represented by `ssl_cert_location` will be assumed to be in binary "
100  "DER format",
101  "default_value": False,
102  },
103  "ssl_cert_location": <DataProviderOptionInfo>{
104  "type": AbstractDataProviderType::get(StringType, NOTHING, {
105  DTT_FromFile: True,
106  DTT_FromLocation: True,
107  }),
108  "desc": "A path or location to an X.509 client certificate file",
109  },
110  "ssl_key_der": <DataProviderOptionInfo>{
111  "type": AbstractDataProviderType::get(BoolType),
112  "desc": "If `True` then the data represented by `ssl_key_location` will be assumed to be in binary "
113  "DER format",
114  "default_value": False,
115  },
116  "ssl_key_location": <DataProviderOptionInfo>{
117  "type": AbstractDataProviderType::get(StringType, NOTHING, {
118  DTT_FromFile: True,
119  DTT_FromLocation: True,
120  }),
121  "desc": "A path or location to a private key file for the X.509 client certificate",
122  },
123  "ssl_key_password": <DataProviderOptionInfo>{
124  "type": AbstractDataProviderType::get(StringType),
125  "desc": "The password to the private key given with `ssl_key_path` (text PEM format only)",
126  "sensitive": True,
127  },
128  "ssl_verify_cert": <DataProviderOptionInfo>{
129  "type": AbstractDataProviderType::get(BoolType),
130  "desc": "if `True` then the server's certificate will only be accepted if it's verified",
131  "default_value": False,
132  },
133  "timeout": <DataProviderOptionInfo>{
134  "type": AbstractDataProviderType::get(IntType),
135  "desc": "Transfer timeout to use in milliseconds (default: 45 seconds)",
136  "default_value": 45000,
137  },
138  "url": <DataProviderOptionInfo>{
139  "type": AbstractDataProviderType::get(StringType),
140  "desc": "A URL for an HTTP or HTTPS connection",
141  "required": True,
142  },
143  };
144 
145  HTTPClient http;
146 
147 protected:
148  const ChildMap = {
149  "call": Class::forName("HttpClientDataProvider::HttpClientCallDataProvider"),
150  "delete": Class::forName("HttpClientDataProvider::HttpClientDeleteDataProvider"),
151  "get": Class::forName("HttpClientDataProvider::HttpClientGetDataProvider"),
152  "head": Class::forName("HttpClientDataProvider::HttpClientHeadDataProvider"),
153  "options": Class::forName("HttpClientDataProvider::HttpClientOptionsDataProvider"),
154  "patch": Class::forName("HttpClientDataProvider::HttpClientPatchDataProvider"),
155  "post": Class::forName("HttpClientDataProvider::HttpClientPostDataProvider"),
156  "put": Class::forName("HttpClientDataProvider::HttpClientPutDataProvider"),
157  };
158 
159 public:
160 
162  constructor(*hash<auto> options);
163 
164 
166  constructor(HTTPClient http);
167 
168 
170  string getName();
171 
172 
174  *string getDesc();
175 
176 
178  *list<hash<DataProviderSummaryInfo>> getChildProviderSummaryInfo();
179 
180 
182  static HTTPClient getHttpConnection(hash<auto> options);
183 
185  static hash<auto> makeRequest(HTTPClient http, string meth, *data body, string path, *hash<auto> hdr);
186 
188 
190 protected:
191  *list<string> getChildProviderNamesImpl();
192 public:
193 
194 
196 
200 protected:
201  *AbstractDataProvider getChildProviderImpl(string name);
202 public:
203 
204 
206 protected:
207  hash<DataProviderInfo> getStaticInfoImpl();
208 public:
209 
210 };
211 };
*string getDesc()
Returns the data provider description.
*list< hash< DataProviderSummaryInfo > > getChildProviderSummaryInfo()
Return data provider summary info.
constructor(*hash< auto > options)
Creates the object from constructor options.
string getName()
Returns the data provider name.
*AbstractDataProvider getChildProviderImpl(string name)
Returns the given child provider or NOTHING if the given child is unknown.
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
constructor(HTTPClient http)
Creates the object from an HTTP connection.
static HTTPClient getHttpConnection(hash< auto > options)
Returns an HTTP connection.
*list< string > getChildProviderNamesImpl()
Returns a list of child data provider names, if any.
static hash< auto > makeRequest(HTTPClient http, string meth, *data body, string path, *hash< auto > hdr)
Makes an HTTP request and returns the response.
const True
const False
const NOTHING
Qore HttpClientDataProvider module definition.
Definition: HttpClientCallDataProvider.qc.dox.h:26