Qore DataStreamClient Module Reference  1.2
DataStreamClient.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file DataStreamClient.qm Qore user module implementing client support for the DataStream protocol: YAML-encoded HTTP chunked transfers where each chunk is a unique data entity
3 
4 /* DataStreamClient.qm Copyright (C) 2014 - 2019 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 // this module requires Qore 0.8.13 or better
26 
27 // require type definitions everywhere
28 
29 // enable all warnings
30 
31 
32 // do not use $ signs in declarations
33 
34 
35 /* Version History: see docs below
36 */
37 
76 namespace DataStreamClient {
80 
81 public:
82 
83 
85 
87  auto sendData();
88 
89 
91 
93 protected:
94  abstract auto sendDataImpl();
95 public:
96  };
97 
100 
101 public:
102  // any datastream error received from the remote end
103  string err;
104 
106 
108  nothing recvData(auto data);
109 
110 
112 
114  nothing recvDataDone(*string err);
115 
116 
118 
120 protected:
121  nothing recvDataDoneImpl(*string err);
122 public:
123 
124 
126 
128 protected:
129  abstract nothing recvDataImpl(auto data);
130 public:
131  };
132 
135 
136 public:
137  };
138 
140 class DataStreamClient : public RestClient::RestClient {
141 
142 public:
144  const Version = "1.1";
145 
147  const VersionString = sprintf("Qore-DataStreamClient/%s", DataStreamClient::Version);
148 
150  const DefaultHeaders = RestClient::DefaultHeaders + {
151  "User-Agent": DataStreamClient::VersionString,
152  DataStreamAccept: MimeTypeYaml,
153  };
154 
156 
177  constructor(*hash<auto> opts, *softbool do_not_connect) ;
178 
179 
181 
210  recvDataStream(code rcb, code ecb, string method, string path, auto body, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
211 
212 
214 
242  recvDataStream(DataStreamRecvMessage dsm, string method, string path, auto body, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
243 
244 
246 
280  hash<auto> sendDataStream(code scb, string method, string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
281 
282 
284 
318  hash<auto> sendDataStream(DataStreamSendMessage dsm, string method, string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
319 
320 
322 
358  sendRecvDataStream(code scb, code rcb, code ecb, string method, string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
359 
360 
362 
396  sendRecvDataStream(DataStreamMessage dsm, string method, string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
397 
398 
400 
428  hash<auto> sendRawStream(code scb, string method, *string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
429 
430 
432 
467  hash<auto> getRawStream(code rcb, string method, *string path, auto body, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
468 
469 
471 
483  addDefaultHeaders(hash<auto> h);
484 
485 
487 
496  setContentEncoding(string enc = 'auto');
497 
498 
500 protected:
501  nothing prepareMsg(string method, string path, reference<auto> body, reference<hash<auto>> hdr, string ct = 'Content-Type');
502 public:
503 
504 
506  hash<auto> sendAndDecodeResponse(*data body, string m, string path, hash<auto> hdr, *reference<hash<auto>> info, *softbool decode_errors);
507 
508  };
509 };
DataStreamClient::DataStreamSendMessage
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:79
DataStreamClient::DataStreamRecvMessage::recvDataImpl
abstract nothing recvDataImpl(auto data)
reimplement this method in subclasses to receive decoded and deserialized data
DataStreamClient::DataStreamClient::sendRecvDataStream
sendRecvDataStream(code scb, code rcb, code ecb, string method, string path, timeout timeout_ms=0, *reference< hash< auto >> info, *hash< auto > hdr)
Sends an HTTP request an HTTP REST server supporting the DataStream protocol with the specified metho...
DataStreamClient::DataStreamClient::setContentEncoding
setContentEncoding(string enc='auto')
sets the request and desired response encoding for the object; see EncodingSupport for valid options
DataStreamClient::DataStreamClient::addDefaultHeaders
addDefaultHeaders(hash< auto > h)
adds default headers to each request; these headers will be sent in all requests but can be overridde...
DataStreamClient::DataStreamClient::recvDataStream
recvDataStream(code rcb, code ecb, string method, string path, auto body, timeout timeout_ms=0, *reference< hash< auto >> info, *hash< auto > hdr)
sends an HTTP request to an HTTP REST server supporting the DataStream protocol and returns the decod...
DataStreamClient::DataStreamSendMessage::sendDataImpl
abstract auto sendDataImpl()
reimplement this method in subclasses to support streamed data transfers; when this method returns no...
DataStreamClient::DataStreamClient::sendRawStream
hash< auto > sendRawStream(code scb, string method, *string path, timeout timeout_ms=0, *reference< hash< auto >> info, *hash< auto > hdr)
send raw chunked data to the client and expect a YAML-formatted response
DataStreamClient::DataStreamRecvMessage
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:99
DataStreamClient::DataStreamClient::constructor
constructor(*hash< auto > opts, *softbool do_not_connect)
calls the base class RestClient constructor and optionally connects to the REST server
DataStreamClient::DataStreamClient::sendRecvDataStream
sendRecvDataStream(DataStreamMessage dsm, string method, string path, timeout timeout_ms=0, *reference< hash< auto >> info, *hash< auto > hdr)
Sends an HTTP request an HTTP REST server supporting the DataStream protocol with the specified metho...
DataStreamClient::DataStreamSendMessage::sendData
auto sendData()
this method returns data to be returned to the server; when this method returns no value,...
DataStreamClient
the DataStreamClient namespace contains all the public objects in the DataStreamClient module
Definition: DataStreamClient.qm.dox.h:77
DataStreamClient::DataStreamClient::prepareMsg
nothing prepareMsg(string method, string path, reference< auto > body, reference< hash< auto >> hdr, string ct='Content-Type')
sets up headers and encodes any body for sending
DataStreamClient::DataStreamRecvMessage::recvDataDoneImpl
nothing recvDataDoneImpl(*string err)
this method is called when all data has been received
DataStreamClient::DataStreamClient::sendAndDecodeResponse
hash< auto > sendAndDecodeResponse(*data body, string m, string path, hash< auto > hdr, *reference< hash< auto >> info, *softbool decode_errors)
sends the outgoing HTTP message and recodes the response to data
DataStreamClient::DataStreamClient::sendDataStream
hash< auto > sendDataStream(DataStreamSendMessage dsm, string method, string path, timeout timeout_ms=0, *reference< hash< auto >> info, *hash< auto > hdr)
Sends an HTTP request to an HTTP REST server supporting the DataStream protocol with the specified me...
DataStreamClient::DataStreamClient::sendDataStream
hash< auto > sendDataStream(code scb, string method, string path, timeout timeout_ms=0, *reference< hash< auto >> info, *hash< auto > hdr)
Sends an HTTP request to an HTTP REST server supporting the DataStream protocol with the specified me...
DataStreamClient::DataStreamMessage
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:134
DataStreamClient::DataStreamClient::recvDataStream
recvDataStream(DataStreamRecvMessage dsm, string method, string path, auto body, timeout timeout_ms=0, *reference< hash< auto >> info, *hash< auto > hdr)
sends an HTTP request to an HTTP REST server supporting the DataStream protocol and returns the decod...
DataStreamClient::DataStreamRecvMessage::recvData
nothing recvData(auto data)
receives decoded data from the remote end and calls recvDataImpl()
DataStreamClient::DataStreamRecvMessage::recvDataDone
nothing recvDataDone(*string err)
this method is called when all data has been received; this method calls recvDataDoneImpl()
DataStreamClient::DataStreamClient::getRawStream
hash< auto > getRawStream(code rcb, string method, *string path, auto body, timeout timeout_ms=0, *reference< hash< auto >> info, *hash< auto > hdr)
receives raw chunked data using the given closure and returns any headers received