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
80
81public:
82
83
85
87 auto sendData();
88
89
91
93protected:
94 abstract auto sendDataImpl();
95public:
96 };
97
100
101public:
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
120protected:
121 nothing recvDataDoneImpl(*string err);
122public:
123
124
126
128protected:
129 abstract nothing recvDataImpl(auto data);
130public:
131 };
132
135
136public:
137 };
138
140class DataStreamClient : public RestClient::RestClient {
141
142public:
144 const Version = "1.1";
145
147 const VersionString = sprintf("Qore-DataStreamClient/%s", DataStreamClient::Version);
148
150 const DefaultHeaders = ...;
151
152
154
175 constructor(*hash<auto> opts, *softbool do_not_connect) ;
176
177
179
208 recvDataStream(code rcb, code ecb, string method, string path, auto body, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
209
210
212
240 recvDataStream(DataStreamRecvMessage dsm, string method, string path, auto body, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
241
242
244
278 hash<auto> sendDataStream(code scb, string method, string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
279
280
282
316 hash<auto> sendDataStream(DataStreamSendMessage dsm, string method, string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
317
318
320
356 sendRecvDataStream(code scb, code rcb, code ecb, string method, string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
357
358
360
394 sendRecvDataStream(DataStreamMessage dsm, string method, string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
395
396
398
426 hash<auto> sendRawStream(code scb, string method, *string path, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
427
428
430
465 hash<auto> getRawStream(code rcb, string method, *string path, auto body, timeout timeout_ms = 0, *reference<hash<auto>> info, *hash<auto> hdr);
466
467
469
481 addDefaultHeaders(hash<auto> h);
482
483
485
494 setContentEncoding(string enc = 'auto');
495
496
498protected:
499 nothing prepareMsg(string method, string path, reference<auto> body, reference<hash<auto>> hdr, string ct = 'Content-Type');
500public:
501
502
504 hash<auto> sendAndDecodeResponse(*data body, string m, string path, hash<auto> hdr, *reference<hash<auto>> info, *softbool decode_errors);
505
506 };
507};
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
setContentEncoding(string enc='auto')
sets the request and desired response encoding for the object; see EncodingSupport for valid options
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...
constructor(*hash< auto > opts, *softbool do_not_connect)
calls the base class RestClient constructor and optionally connects to the REST server
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...
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
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...
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...
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...
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...
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
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
addDefaultHeaders(hash< auto > h)
adds default headers to each request; these headers will be sent in all requests but can be overridde...
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:134
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:99
nothing recvData(auto data)
receives decoded data from the remote end and calls recvDataImpl()
nothing recvDataDone(*string err)
this method is called when all data has been received; this method calls recvDataDoneImpl()
abstract nothing recvDataImpl(auto data)
reimplement this method in subclasses to receive decoded and deserialized data
nothing recvDataDoneImpl(*string err)
this method is called when all data has been received
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:79
abstract auto sendDataImpl()
reimplement this method in subclasses to support streamed data transfers; when this method returns no...
auto sendData()
this method returns data to be returned to the server; when this method returns no value,...
the DataStreamClient namespace contains all the public objects in the DataStreamClient module
Definition: DataStreamClient.qm.dox.h:77