|
Qore RestClient Module Reference
1.2
|
this class provides the REST client API More...

Public Member Functions | |
| constructor (*hash opts, *softbool do_not_connect) | |
| calls the base class HTTPClient constructor and optionally connects to the REST server More... | |
| decodeResponse (reference h, *reference info) | |
| decodes the response | |
| hash | del (string path, any body, *reference info, *hash hdr) |
| sends an HTTP DELETE request to the REST server and returns the response More... | |
| hash | doRequest (string m, string path, any body, *reference info, *softbool decode_errors, *hash hdr) |
| sends an HTTP request to the REST server and returns the response More... | |
| hash | get (string path, any body, *reference info, *hash hdr) |
| sends an HTTP GET request to the REST server and returns the response More... | |
| string | getSerialization () |
| returns the current data serialization format currently in effect for the object (see DataSerializationOptions for possible values) More... | |
| hash | post (string path, any body, *reference info, *hash hdr) |
| sends an HTTP POST request to the REST server and returns the response More... | |
| private nothing | prepareMsg (reference body, reference hdr, string ct="Content-Type") |
| sets up the Content-Type header and encodes any body for sending | |
| private nothing | preparePath (reference path) |
| sets up the path for the HTTP request URI | |
| hash | put (string path, any body, *reference info, *hash hdr) |
| sends an HTTP PUT request to the REST server and returns the response More... | |
| setSendEncoding (string enc="auto") | |
| change the serialization option for the object; see DataSerializationOptions for valid options More... | |
| setSerialization (string data="auto") | |
| change the serialization option for the object; see DataSerializationOptions for valid options More... | |
Public Attributes | |
| const | Accept = AcceptList.join(",") |
| Accept header value. | |
| const | AcceptList |
| Accept header list. | |
| const | DataDeserializationSupport |
| Data deserialization support MIME types to codes and de/serialization functions. | |
| const | DataSerializationOptions |
| Data serialization options; this is a hash to simulate a set of strings. More... | |
| const | DataSerializationSupport |
| Data serialization support mapping codes to MIME types and de/serialization functions. | |
| const | DefaultHeaders |
| default HTTP headers (Content-Type is added before sending) | |
| const | EncodingSupport |
| Send content encoding options. More... | |
| const | Version = "1.2" |
| RestClient Version. | |
| const | VersionString = sprintf("Qore-RestClient/%s", RestClient::Version) |
| RestClient Version String. | |
this class provides the REST client API
| RestClient::RestClient::constructor | ( | *hash | opts, |
| *softbool | do_not_connect | ||
| ) |
calls the base class HTTPClient constructor and optionally connects to the REST server
| opts | valid options are:
|
| do_not_connect | if False (the default), then a connection will be immediately established to the remote server |
| RESTCLIENT-ERROR | invalid option passed to constructor, unsupported data serialization, etc |
sends an HTTP DELETE request to the REST server and returns the response
| path | the URI path to add (will be appended to any root path given in the constructor) |
| body | an optional message body to be included in the request; if a value for this parameter is passed to the method, then the body will be serialized according to the serialization rules set in RestClient::constructor() |
| info | an optional reference to a hash that will be used as an output variable giving a hash of request headers and other information about the HTTP request |
| hdr | any headers to be sent with the request; headers here will override default headers for the object as well |
"body" key| DESERIALIZATION-ERROR | the response body could not be deserialized (unknown Content-Type or invalid serialization) |
| hash RestClient::RestClient::doRequest | ( | string | m, |
| string | path, | ||
| any | body, | ||
| *reference | info, | ||
| *softbool | decode_errors, | ||
| *hash | hdr | ||
| ) |
sends an HTTP request to the REST server and returns the response
| m | the HTTP method to be used; case is ignored (if not a valid method an HTTP-CLIENT-METHOD-ERROR exception is raised) |
| path | the URI path to add (will be appended to any root path given in the constructor) |
| body | an optional message body to be included in the request; if a value for this parameter is passed to the method, then the body will be serialized according to the serialization rules set in RestClient::constructor() |
| info | an optional reference to a hash that will be used as an output variable giving a hash of request headers and other information about the HTTP request |
| decode_errors | decode the message body with HTTP error responses and throw an exception based on the message body |
| hdr | any headers to be sent with the request; headers here will override default headers for the object as well |
"body" key| DESERIALIZATION-ERROR | the response body could not be deserialized (unknown Content-Type or invalid serialization) |
| HTTP-CLIENT-METHOD-ERROR | invalid HTTP method argument passed |
sends an HTTP GET request to the REST server and returns the response
| path | the URI path to add (will be appended to any root path given in the constructor) |
| body | an optional message body to be included in the request; if a value for this parameter is passed to the method, then the body will be serialized according to the serialization rules set in RestClient::constructor() |
| info | an optional reference to a hash that will be used as an output variable giving a hash of request headers and other information about the HTTP request |
| hdr | any headers to be sent with the request; headers here will override default headers for the object as well |
"body" key| DESERIALIZATION-ERROR | the response body could not be deserialized (unknown Content-Type or invalid serialization) |
| string RestClient::RestClient::getSerialization | ( | ) |
returns the current data serialization format currently in effect for the object (see DataSerializationOptions for possible values)
sends an HTTP POST request to the REST server and returns the response
| path | the URI path to add (will be appended to any root path given in the constructor) |
| body | an optional message body to be included in the request; if a value for this parameter is passed to the method, then the body will be serialized according to the serialization rules set in RestClient::constructor() |
| info | an optional reference to a hash that will be used as an output variable giving a hash of request headers and other information about the HTTP request |
| hdr | any headers to be sent with the request; headers here will override default headers for the object as well |
"body" key| DESERIALIZATION-ERROR | the response body could not be deserialized (unknown Content-Type or invalid serialization) |
sends an HTTP PUT request to the REST server and returns the response
| path | the URI path to add (will be appended to any root path given in the constructor) |
| body | an optional message body to be included in the request; if a value for this parameter is passed to the method, then the body will be serialized according to the serialization rules set in RestClient::constructor() |
| info | an optional reference to a hash that will be used as an output variable giving a hash of request headers and other information about the HTTP request |
| hdr | any headers to be sent with the request; headers here will override default headers for the object as well |
"body" key| DESERIALIZATION-ERROR | the response body could not be deserialized (unknown Content-Type or invalid serialization) |
| RestClient::RestClient::setSendEncoding | ( | string | enc = "auto" | ) |
change the serialization option for the object; see DataSerializationOptions for valid options
| data | the serialization option for the object; see DataSerializationOptions for valid options |
| RESTCLIENT-ERROR | invalid or unsupported serialization option |
| RestClient::RestClient::setSerialization | ( | string | data = "auto" | ) |
change the serialization option for the object; see DataSerializationOptions for valid options
| data | the serialization option for the object; see DataSerializationOptions for valid options |
| RESTCLIENT-ERROR | invalid or unsupported serialization option |
| const RestClient::RestClient::DataSerializationOptions |
Data serialization options; this is a hash to simulate a set of strings.
Data serialization options are as follows:
"auto": prefers in this order: json, yaml, xml-rpc"xml": use only XML-RPC serialization"json": use only JSON serialization"yaml": use only YAML serialization | const RestClient::RestClient::EncodingSupport |
Send content encoding options.
Send content encoding options are as follows:
"bzip": use bzip2 compression"gzip": use gzip compression"deflate": use deflate compression