204 const DataSerializationSupport = {
206 "json": MimeTypeJson,
209 "yaml": MimeTypeYaml,
213 "rawxml": MimeTypeXmlApp,
215 "url": MimeTypeFormUrlEncoded,
216 "text": MimeTypeText,
217 "bin": MimeTypeOctetStream,
220 const DeserializeYaml = {
224 const DeserializeXml = {
227 "in": hash<auto> sub (
string xml, reference<string> type) {
229 on_success type =
"xml";
230 return parse_xmlrpc_value(xml);
231 }
catch (hash<ExceptionInfo> ex) {
233 on_success
type =
"rawxml";
234 return parse_xml(xml);
243 const AcceptList = ...;
247 const Accept = AcceptList.join(
",");
250 const AcceptMap = map {$1: True}, AcceptList;
253 const Version =
"1.7";
259 const DefaultHeaders = {
275 const DataSerializationOptions = {
299 const EncodingSupport = {
318 const CompressionThreshold = 1024;
398 constructor(*hash<auto> opts, *softbool do_not_connect) : HTTPClient(opts + ((opts.url || !opts.validator)
406 clearConnectionPath();
421 setSerialization(
string data =
'auto');
440 setSendEncoding(
string enc =
'auto');
459 setContentEncoding(
string enc =
'auto');
477 addDefaultHeaders(hash<auto> h);
494 hash<auto> getDefaultHeaders();
511 *
string getSendEncoding();
524 string getSerialization();
569 hash<auto> get(
string path,
auto body, *reference<hash<auto>> info, *hash<auto> hdr);
613 hash<auto> put(
string path,
auto body, *reference<hash<auto>> info, *hash<auto> hdr);
657 hash<auto> patch(
string path,
auto body, *reference<hash<auto>> info, *hash<auto> hdr);
712 hash<auto> post(
string path,
auto body, *reference<hash<auto>> info, *hash<auto> hdr);
767 hash<auto> del(
string path,
auto body, *reference<hash<auto>> info, *hash<auto> hdr);
779 private nothing prepareMsg(
string method,
string path, reference<auto> body, reference<hash<auto>> hdr,
780 string ct =
"Content-Type") {
782 hdr = {} + headers + hdr;
785 if (!path.val() && (*
string p = getConnectionPath()))
788 hash<RestRequestClientInfo> req = validator.
processRequest(method, path, body, hdr, sct);
796 nothing preparePath(reference<string> path);
861 hash<auto> doRequest(
string m,
string path,
auto body, *reference<hash<auto>> info, softbool decode_errors = True,
863 prepareMsg(m, path, \body, \hdr);
865 on_exit
if (exists body);
871 return sendAndDecodeResponse(body, m, path, hdr, \info, decode_errors);
877 hash<auto> doValidatedRequest(
string m,
string path,
auto body, *reference<hash<auto>> info,
878 softbool decode_errors = True, *hash<auto> hdr) {
880 hdr = {} + headers + hdr;
882 on_exit
if (exists body);
885 return sendAndDecodeResponse(body, m, path, hdr, \info, decode_errors);
889 private hash<auto> sendAndDecodeResponse(*data body,
string m,
string path, hash<auto> hdr,
890 *reference<hash<auto>> info, *softbool decode_errors) {
893 h = send(body, m, path, hdr, False, \info);
894 info.
"response-code" = h.status_code;
895 }
catch (hash<ExceptionInfo> ex) {
896 info.
"response-code" = info.
"response-headers".status_code;
898 if (decode_errors && ex.arg.body) {
899 decodeError(ex.arg, \info);
900 ex.arg.deserialized_body = info.
"response-body";
904 rethrow ex.err, ex.desc, ex.arg;
908 if (exists h.body && !exists info.
"response-body") {
909 info.
"response-body" = h.body;
913 return processRestResponse(h, m, path, \info);
925 hash<auto> processRestResponse(hash<auto> resp,
string method,
string path, *reference<hash<auto>> info);
931 static decodeError(hash<auto> h, *reference<hash<auto>> info);
937 static tryDecodeErrorResponse(reference<hash<auto>> h, *reference<hash<auto>> info);
992 "cls": Class::forName(
"RestConnection"),
993 "options": HttpConnection::ConnectionScheme.options + {
994 "content_encoding": <ConnectionOptionInfo>{
996 "desc":
"this sets the send encoding (if the `send_encoding` option is not set) and the "
997 "response encoding to request",
1001 "desc":
"use GNU zip encoding ([RFC 1952](https://tools.ietf.org/html/rfc1952))",
1002 }, <AllowedValueInfo>{
1004 "desc":
"use bzip2 encoding",
1005 }, <AllowedValueInfo>{
1007 "desc":
"use the deflate algorithm ([RFC 1951](https://tools.ietf.org/html/rfc1951))",
1008 }, <AllowedValueInfo>{
1009 "value":
"identity",
1010 "desc":
"use no content encoding",
1014 "data": <ConnectionOptionInfo>{
1016 "desc":
"data serialization options",
1020 "desc":
"prefers in this order: `json`, `yaml`, `rawxml`, `xml`, `url`, and `text`",
1021 }, <AllowedValueInfo>{
1023 "desc":
"for binary message bodies without data serialization",
1024 }, <AllowedValueInfo>{
1026 "desc":
"use JSON serialization",
1027 }, <AllowedValueInfo>{
1029 "desc":
"use raw XML serialization",
1030 }, <AllowedValueInfo>{
1032 "desc":
"use only plain text; no serialization is used",
1033 }, <AllowedValueInfo>{
1035 "desc":
"for URL-encoded message bodies",
1036 }, <AllowedValueInfo>{
1038 "desc":
"use only XML-RPC serialization",
1039 }, <AllowedValueInfo>{
1041 "desc":
"use only YAML serialization",
1044 "default_value":
"auto",
1046 "headers": <ConnectionOptionInfo>{
1048 "desc":
"an optional hash of headers to send with every request, these can also be "
1049 "overridden in request method calls",
1051 "send_encoding": <ConnectionOptionInfo>{
1053 "desc":
"this sets the send encoding",
1057 "desc":
"use GNU zip encoding ([RFC 1952](https://tools.ietf.org/html/rfc1952))",
1058 }, <AllowedValueInfo>{
1060 "desc":
"use bzip2 encoding",
1061 }, <AllowedValueInfo>{
1063 "desc":
"use the deflate algorithm ([RFC 1951](https://tools.ietf.org/html/rfc1951))",
1064 }, <AllowedValueInfo>{
1065 "value":
"identity",
1066 "desc":
"use no content encoding",
1070 "swagger": <ConnectionOptionInfo>{
1072 "desc":
"the location of a Swagger schema to use for message validation; processed with "
1073 "`FileLocationHandler::getTextFileFromLocation()` "
1074 "(ex: `file:///path/to/swagger-schema.json`); conflicts with `validator`",
1076 "swagger_base_path": <ConnectionOptionInfo>{
1078 "desc":
"in case a REST validator is used, the base path in the schema can be overridden "
1079 "with this option (applies to any REST validator; not just Swagger validators)",
1080 "subst_env_vars": True,
1082 "validator": <ConnectionOptionInfo>{
1084 "desc":
"an `AbstractRestSchemaValidator` object for REST message validation; conflicts with "
1114 constructor(
string name,
string description,
string url, hash<auto> attributes = {}, hash<auto> options = {})
const VersionString
RestClient Version String.
Definition: RestClient.qm.dox.h:256
const Version
RestClient Version.
Definition: RestClient.qm.dox.h:253
class for REST HTTP connections; returns RestClient::RestClient objects
Definition: RestClient.qm.dox.h:984
bool hasDataProvider()
returns True, as this connection always returns a data provider with the getDataProvider() method
*hash< auto > getDefaultOptions()
returns default options
const OptionList
object connection option list
Definition: RestClient.qm.dox.h:1098
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the RestConnection connection object
hash< auto > real_opts
real options used when creating an object
Definition: RestClient.qm.dox.h:988
const Options
object connection options
Definition: RestClient.qm.dox.h:1091
const DefaultOptions
default options
Definition: RestClient.qm.dox.h:1094
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Returns the ConnectionSchemeInfo hash for this object.
object getPollImpl()
Returns an unconnected object for a non-blocking poll operation.
setChildCapabilities()
Sets child data provider capabilities.
RestClient getImpl(bool connect=True, *hash< auto > rtopts)
returns a RestClient object
static hash< auto > processOptions(*hash< auto > opts)
processes options for the constructor
hash< auto > getOptions()
gets options
const ConnectionScheme
Connection entry info.
Definition: RestClient.qm.dox.h:991
string getType()
returns "rest"
DataProvider::AbstractDataProvider getDataProvider()
returns a data provider object for this connection
hash< RestRequestClientInfo > processRequest(string method, string path, auto body, *hash< auto > headers, *softlist< string > content_types)
the RestClient namespace contains all the objects in the RestClient module
Definition: RestClient.qm.dox.h:198