Loading...
Searching...
No Matches
HttpConnection.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// Qore HttpConnection class definition
/* HttpConnection.qc Copyright 2016 - 2023 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
namespace ConnectionProvider {
class HttpConnection : public AbstractConnectionWithInfo {
public:
const ConnectionScheme = <ConnectionSchemeInfo>{
"cls": Class::forName("HttpConnection"),
"options": {
"assume_encoding": <ConnectionOptionInfo>{
"type": "string",
"desc": "assumes the given encoding if the server does not send a `charset` value",
},
"connect_timeout": <ConnectionOptionInfo>{
"type": "int",
"desc": "connection timeout to use in milliseconds (default: 45 seconds)",
"default_value": 45000,
},
"error_passthru": <ConnectionOptionInfo>{
"type": "bool",
"desc": "if `True` then HTTP status codes indicating errors will not cause an "
"`HTTP-CLIENT-RECEIVE-ERROR` exception to be raised, rather such responses will be "
"passed through to the caller like any other response",
"default_value": False,
},
"headers": <ConnectionOptionInfo>{
"type": "hash",
"desc": "headers to add in each outgoing request",
},
"http_version": <ConnectionOptionInfo>{
"type": "string",
"desc": "HTTP version to use (`1.0` or `1.1`, defaults to `1.1`)",
"default_value": "1.1",
"allowed_values": (
<AllowedValueInfo>{
"value": "1.0",
"desc": "For HTTP 1.0",
},
<AllowedValueInfo>{
"value": "1.1",
"desc": "For HTTP 1.1",
},
),
},
"max_redirects": <ConnectionOptionInfo>{
"type": "int",
"desc": "maximum redirects to support",
},
"pre_encoded_urls": <ConnectionOptionInfo>{
"type": "bool",
"desc": "if `true` then all URI paths in URLs are assumed to be already "
"[percent encoded](https://en.wikipedia.org/wiki/Percent-encoding); if this flag is set and "
"any unencoded characters are sent in a URL with a new request, an exception is raised",
},
"proxy": <ConnectionOptionInfo>{
"type": "string",
"desc": "proxy URL to use",
},
"redirect_passthru": <ConnectionOptionInfo>{
"type": "bool",
"desc": "if `True` then redirect responses will be passed to the caller instead of processed",
"default_value": False,
},
"ssl_cert_data": <ConnectionOptionInfo>{
"type": "data",
"desc": "the X.509 certificate data in PEM format (string) or in DER format (binary); if this "
"option is set, then `ssl_cert_path` is ignored",
},
"ssl_cert_path": <ConnectionOptionInfo>{
"type": "string",
"desc": "a path to an X.509 client certificate file in PEM format",
"subst_env_vars": True,
},
"ssl_key_password": <ConnectionOptionInfo>{
"type": "string",
"desc": "the password to the private key given with `ssl_key_path`",
"sensitive": True,
},
"ssl_key_data": <ConnectionOptionInfo>{
"type": "data",
"desc": "the X.509 private key data in PEM format (string) or in DER format (binary); if this "
"option is set, then `ssl_key_path` is ignored",
},
"ssl_key_path": <ConnectionOptionInfo>{
"type": "string",
"desc": "a path to a private key file in PEM format for the X.509 client certificate",
"subst_env_vars": True,
},
"ssl_verify_cert": <ConnectionOptionInfo>{
"type": "bool",
"desc": "if `True` then the server's certificate will only be accepted if it's verified",
"default_value": False,
},
"timeout": <ConnectionOptionInfo>{
"type": "int",
"desc": "transfer timeout to use in milliseconds (default: 45 seconds)",
"default_value": 45000,
},
},
};
const Options = map {$1: True}, keys ConnectionScheme.options;
constructor(string name, string desc, string url, hash<auto> attributes = {}, hash<auto> options = {})
;
string getType();
DataProvider::AbstractDataProvider getDataProvider();
bool hasDataProvider();
bool supportsPollingApi();
Qore::AbstractPollOperation startPollConnect();
protected:
setChildCapabilities();
public:
protected:
Qore::HTTPClient getImpl(bool connect = True, *hash<auto> rtopts);
public:
protected:
hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
public:
};
}; // 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:55
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:59
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:155
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::startPollConnect
Qore::AbstractPollOperation startPollConnect()
Called to start the connection if the connection supports the polling API.
Qore::AbstractPollOperation
Qore::HTTPClient
ConnectionProvider
The ConnectionProvider namespace.
Definition: AbstractConnection.qc.dox.h:28
ConnectionProvider::AllowedValueInfo
Allowed value hash.
Definition: ConnectionSchemeCache.qc.dox.h:29
ConnectionProvider::ConnectionOptionInfo
Connection option information.
Definition: ConnectionSchemeCache.qc.dox.h:38
ConnectionProvider::ConnectionSchemeInfo
Connection provider information.
Definition: ConnectionSchemeCache.qc.dox.h:62