Qore DataStreamClient Module Reference  1.1
 All Classes Namespaces Functions Variables Groups Pages
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 - 2017 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 
72 namespace DataStreamClient {
76 
77 public:
78 private:
79 
80 public:
81 
83 
85  any sendData();
86 
87 
89 
92 private:
93  abstract any sendDataImpl();
94 public:
95  };
96 
99 
100 public:
101  public :
102  // any datastream error received from the remote end
103  string err;
104 
105 public:
106 
108 
110  nothing recvData(any data);
111 
112 
114 
116  nothing recvDataDone(*string err);
117 
118 
120 
123 private:
124  nothing recvDataDoneImpl(*string err);
125 public:
126 
127 
129 
132 private:
133  abstract nothing recvDataImpl(any data);
134 public:
135  };
136 
139 
140 public:
141  };
142 
144 class DataStreamClient : public RestClient::RestClient {
145 
146 public:
147  public :
149  const Version = "1.1";
150 
152  const VersionString = sprintf("Qore-DataStreamClient/%s", DataStreamClient::Version);
153 
155  const DefaultHeaders = RestClient::DefaultHeaders + (
156  "User-Agent": DataStreamClient::VersionString,
157  DataStreamAccept: MimeTypeYaml,
158  );
159 
160 public:
161 
163 
184  constructor(*hash opts, *softbool do_not_connect) ;
185 
186 
188 
217  recvDataStream(code rcb, code ecb, string method, string path, any body, timeout timeout_ms = 0, *reference<hash> info, *hash hdr);
218 
219 
221 
249  recvDataStream(DataStreamRecvMessage dsm, string method, string path, any body, timeout timeout_ms = 0, *reference<hash> info, *hash hdr);
250 
251 
253 
287  hash sendDataStream(code scb, string method, string path, timeout timeout_ms = 0, *reference<hash> info, *hash hdr);
288 
289 
291 
325  hash sendDataStream(DataStreamSendMessage dsm, string method, string path, timeout timeout_ms = 0, *reference<hash> info, *hash hdr);
326 
327 
329 
365  sendRecvDataStream(code scb, code rcb, code ecb, string method, string path, timeout timeout_ms = 0, *reference<hash> info, *hash hdr);
366 
367 
369 
403  sendRecvDataStream(DataStreamMessage dsm, string method, string path, timeout timeout_ms = 0, *reference<hash> info, *hash hdr);
404 
405 
407 
435  hash sendRawStream(code scb, string method, *string path, timeout timeout_ms = 0, *reference<hash> info, *hash hdr);
436 
437 
439 
474  hash getRawStream(code rcb, string method, *string path, any body, timeout timeout_ms = 0, *reference<hash> info, *hash hdr);
475 
476 
478 
490  addDefaultHeaders(hash h);
491 
492 
494 
503  setContentEncoding(string enc = "auto");
504 
505 
507 
508 private:
509  nothing prepareMsg(string method, string path, reference body, reference<hash> hdr, string ct = "Content-Type");
510 public:
511 
512 
514  hash sendAndDecodeResponse(*data body, string m, string path, hash hdr, *reference<hash> info, *softbool decode_errors);
515 
516  };
517 };
sendRecvDataStream(code scb, code rcb, code ecb, string method, string path, timeout timeout_ms=0, *reference< hash > info, *hash hdr)
Sends an HTTP request an HTTP REST server supporting the DataStream protocol with the specified metho...
recvDataStream(code rcb, code ecb, string method, string path, any body, timeout timeout_ms=0, *reference< hash > info, *hash hdr)
sends an HTTP request to an HTTP REST server supporting the DataStream protocol and returns the decod...
nothing prepareMsg(string method, string path, reference body, reference< hash > hdr, string ct="Content-Type")
sets up headers and encodes any body for sending
hash sendAndDecodeResponse(*data body, string m, string path, hash hdr, *reference< hash > info, *softbool decode_errors)
sends the outgoing HTTP message and recodes the response to data
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:75
nothing recvDataDoneImpl(*string err)
this method is called when all data has been received
hash sendRawStream(code scb, string method, *string path, timeout timeout_ms=0, *reference< hash > info, *hash hdr)
send raw chunked data to the client and expect a YAML-formatted response
const Version
DataStreamClient Version.
Definition: DataStreamClient.qm.dox.h:149
const DefaultHeaders
default HTTP headers
Definition: DataStreamClient.qm.dox.h:155
nothing recvDataDone(*string err)
this method is called when all data has been received; this method calls recvDataDoneImpl() ...
abstract any sendDataImpl()
reimplement this method in subclasses to support streamed data transfers; when this method returns no...
setContentEncoding(string enc="auto")
sets the request and desired response encoding for the object; see EncodingSupport for valid options ...
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:98
nothing recvData(any data)
receives decoded data from the remote end and calls recvDataImpl()
addDefaultHeaders(hash h)
adds default headers to each request; these headers will be sent in all requests but can be overridde...
any sendData()
this method returns data to be returned to the server; when this method returns no value...
const VersionString
DataStreamClient Version String.
Definition: DataStreamClient.qm.dox.h:152
hash getRawStream(code rcb, string method, *string path, any body, timeout timeout_ms=0, *reference< hash > info, *hash hdr)
receives raw chunked data using the given closure and returns any headers received ...
this class can be used to send and receive data using the DataStream protocol
Definition: DataStreamClient.qm.dox.h:138
constructor(*hash opts, *softbool do_not_connect)
calls the base class RestClient constructor and optionally connects to the REST server ...
abstract nothing recvDataImpl(any data)
reimplement this method in subclasses to receive decoded and deserialized data
hash sendDataStream(code scb, string method, string path, timeout timeout_ms=0, *reference< hash > info, *hash hdr)
Sends an HTTP request to an HTTP REST server supporting the DataStream protocol with the specified me...
this class extends RestClient with support for the DataStream protocol
Definition: DataStreamClient.qm.dox.h:144
const DataStreamAccept