$darkmode

| Qore ConnectionProvider Module Reference 1.7.4

HttpConnection.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
2// Qore HttpConnection class definition
3
4/* HttpConnection.qc Copyright 2016 - 2023 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
25
27
29 namespace ConnectionProvider {
31
53 class HttpConnection : public AbstractConnectionWithInfo {
54
55 public:
57 const ConnectionScheme = <ConnectionSchemeInfo>{
58 "cls": Class::forName("FilesystemConnection"),
59 "options": {
60 "assume_encoding": <ConnectionOptionInfo>{
61 "type": "string",
62 "desc": "assumes the given encoding if the server does not send a `charset` value",
63 },
64 "connect_timeout": <ConnectionOptionInfo>{
65 "type": "int",
66 "desc": "connection timeout to use in milliseconds (default: 45 seconds)",
67 "default_value": 45000,
68 },
69 "error_passthru": <ConnectionOptionInfo>{
70 "type": "bool",
71 "desc": "if `True` then HTTP status codes indicating errors will not cause an "
72 "`HTTP-CLIENT-RECEIVE-ERROR` exception to be raised, rather such responses will be "
73 "passed through to the caller like any other response",
74 "default_value": False,
75 },
76 "http_version": <ConnectionOptionInfo>{
77 "type": "string",
78 "desc": "HTTP version to use (`1.0` or `1.1`, defaults to `1.1`)",
79 "default_value": "1.1",
80 },
81 "max_redirects": <ConnectionOptionInfo>{
82 "type": "int",
83 "desc": "maximum redirects to support",
84 },
85 "pre_encoded_urls": <ConnectionOptionInfo>{
86 "type": "bool",
87 "desc": "if `true` then all URI paths in URLs are assumed to be already "
88 "[percent encoded](https://en.wikipedia.org/wiki/Percent-encoding); if this flag is set and "
89 "any unencoded characters are sent in a URL with a new request, an exception is raised",
90 },
91 "proxy": <ConnectionOptionInfo>{
92 "type": "string",
93 "desc": "proxy URL to use",
94 },
95 "redirect_passthru": <ConnectionOptionInfo>{
96 "type": "bool",
97 "desc": "if `True` then redirect responses will be passed to the caller instead of processed",
98 "default_value": False,
99 },
100 "ssl_cert_data": <ConnectionOptionInfo>{
101 "type": "data",
102 "desc": "the X.509 certificate data in PEM format (string) or in DER format (binary); if this "
103 "option is set, then `ssl_cert_path` is ignored",
104 },
105 "ssl_cert_path": <ConnectionOptionInfo>{
106 "type": "string",
107 "desc": "a path to an X.509 client certificate file in PEM format",
108 "subst_env_vars": True,
109 },
110 "ssl_key_password": <ConnectionOptionInfo>{
111 "type": "string",
112 "desc": "the password to the private key given with `ssl_key_path`",
113 "sensitive": True,
114 },
115 "ssl_key_data": <ConnectionOptionInfo>{
116 "type": "data",
117 "desc": "the X.509 private key data in PEM format (string) or in DER format (binary); if this "
118 "option is set, then `ssl_key_path` is ignored",
119 },
120 "ssl_key_path": <ConnectionOptionInfo>{
121 "type": "string",
122 "desc": "a path to a private key file in PEM format for the X.509 client certificate",
123 "subst_env_vars": True,
124 },
125 "ssl_verify_cert": <ConnectionOptionInfo>{
126 "type": "bool",
127 "desc": "if `True` then the server's certificate will only be accepted if it's verified",
128 "default_value": False,
129 },
130 "timeout": <ConnectionOptionInfo>{
131 "type": "int",
132 "desc": "transfer timeout to use in milliseconds (default: 45 seconds)",
133 "default_value": 45000,
134 },
135 },
136 };
137
139 const Options = map {$1: True}, keys ConnectionScheme.options;
140
142 const DefaultOptions = ...;
143
144
146
156 constructor(string name, string desc, string url, hash<auto> attributes = {}, hash<auto> options = {})
157 ;
158
159
161 string getType();
162
163
165
169 DataProvider::AbstractDataProvider getDataProvider();
170
171
173
177 bool hasDataProvider();
178
179
181
185 bool supportsPollingApi();
186
187
189
196 Qore::AbstractPollOperation startPollConnect();
197
198
200 protected:
201 setChildCapabilities();
202 public:
203
204
206
209 protected:
210 Qore::HTTPClient getImpl(bool connect = True, *hash<auto> rtopts);
211 public:
212
213
215 protected:
216 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
217 public:
218
219};
220}; // ConnectionProvider namespace
ConnectionProvider::AbstractConnection::desc
string desc
connection description
Definition: AbstractConnection.qc.dox.h:41
ConnectionProvider::AbstractConnection::url
string url
connection URL (potentially with password info)
Definition: AbstractConnection.qc.dox.h:44
ConnectionProvider::AbstractConnection::name
string name
connection name
Definition: AbstractConnection.qc.dox.h:38
ConnectionProvider::AbstractConnectionWithInfo
abstract base class for connections
Definition: AbstractConnectionWithInfo.qc.dox.h:32
ConnectionProvider::HttpConnection
class for HTTP connections; returns Qore::HTTPClient objects
Definition: HttpConnection.qc.dox.h:53
ConnectionProvider::HttpConnection::getDataProvider
DataProvider::AbstractDataProvider getDataProvider()
Returns an HttpDataProvider object for this connection.
ConnectionProvider::HttpConnection::hasDataProvider
bool hasDataProvider()
Returns True, as the connection returns a data provider with the getDataProvider() method.
ConnectionProvider::HttpConnection::ConnectionScheme
const ConnectionScheme
Connection entry info.
Definition: HttpConnection.qc.dox.h:57
ConnectionProvider::HttpConnection::constructor
constructor(string name, string desc, string url, hash< auto > attributes={}, hash< auto > options={})
Creates the HttpConnection object.
ConnectionProvider::HttpConnection::getImpl
Qore::HTTPClient getImpl(bool connect=True, *hash< auto > rtopts)
returns an Qore::HTTPClient object
ConnectionProvider::HttpConnection::getConnectionSchemeInfoImpl
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
ConnectionProvider::HttpConnection::getType
string getType()
Returns "http".
ConnectionProvider::HttpConnection::Options
const Options
HttpConnection object connection options.
Definition: HttpConnection.qc.dox.h:139
ConnectionProvider::HttpConnection::supportsPollingApi
bool supportsPollingApi()
returns True, since this connection type supports the Qore Socket-based polling API
ConnectionProvider::HttpConnection::setChildCapabilities
setChildCapabilities()
Sets child data provider capabilities.
ConnectionProvider::HttpConnection::DefaultOptions
const DefaultOptions
HttpConnection default options.
Definition: HttpConnection.qc.dox.h:142
ConnectionProvider::HttpConnection::startPollConnect
Qore::AbstractPollOperation startPollConnect()
Called to start the connection if the connection supports the polling API.
Qore::AbstractPollOperation
Qore::HTTPClient
True
const True
False
const False
ConnectionProvider
The ConnectionProvider namespace.
Definition: AbstractConnection.qc.dox.h:28
ConnectionProvider::ConnectionOptionInfo
Connection option information.
Definition: ConnectionSchemeCache.qc.dox.h:38
ConnectionProvider::ConnectionSchemeInfo
Connection provider information.
Definition: ConnectionSchemeCache.qc.dox.h:59