Qore Programming Language
0.8.7
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
qore
QoreHTTPClient.h
1
/* -*- mode: c++; indent-tabs-mode: nil -*- */
2
/*
3
QoreHTTPClient.h
4
5
Qore Programming Language
6
7
Copyright (C) 2006 - 2013 QoreTechnologies
8
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Lesser General Public
11
License as published by the Free Software Foundation; either
12
version 2.1 of the License, or (at your option) any later version.
13
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Lesser General Public License for more details.
18
19
You should have received a copy of the GNU Lesser General Public
20
License along with this library; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
*/
23
24
#ifndef QORE_HTTP_CLIENT_H_
25
#define QORE_HTTP_CLIENT_H_
26
27
#include <
qore/common.h
>
28
#include <qore/AbstractPrivateData.h>
29
#include <qore/QoreThreadLock.h>
30
#include <qore/QoreSocket.h>
31
32
#define HTTPCLIENT_DEFAULT_PORT 80
33
#define HTTPCLIENT_DEFAULT_HOST "localhost"
34
35
#define HTTPCLIENT_DEFAULT_TIMEOUT 300000
36
37
#define HTTPCLIENT_DEFAULT_MAX_REDIRECTS 5
38
39
class
Queue;
40
42
44
class
QoreHTTPClient
:
public
AbstractPrivateData
{
45
private
:
47
struct
qore_qtc_private *priv;
48
50
DLLLOCAL
QoreHTTPClient
(
const
QoreHTTPClient
&);
51
53
DLLLOCAL QoreHTTPClient& operator=(
const
QoreHTTPClient&);
54
55
protected
:
56
DLLEXPORT
void
lock();
57
DLLEXPORT
void
unlock();
58
59
public
:
61
DLLEXPORT
QoreHTTPClient
();
62
64
DLLEXPORT
virtual
~QoreHTTPClient
();
65
67
84
DLLEXPORT
int
setOptions
(
const
QoreHashNode
*opts,
ExceptionSink
* xsink);
85
87
89
DLLEXPORT
void
setDefaultPort
(
int
prt);
90
92
94
DLLEXPORT
void
setDefaultPath
(
const
char
*pth);
95
97
99
DLLEXPORT
void
addProtocol
(
const
char
*prot,
int
port,
bool
ssl =
false
);
100
102
DLLEXPORT
void
setTimeout
(
int
to);
103
105
DLLEXPORT
int
getTimeout
()
const
;
106
108
DLLEXPORT
void
setEncoding
(
const
QoreEncoding
*qe);
109
111
DLLEXPORT
const
QoreEncoding
*
getEncoding
()
const
;
112
114
119
DLLEXPORT
int
setHTTPVersion
(
const
char
* version,
ExceptionSink
* xsink);
120
122
125
DLLEXPORT
const
char
*
getHTTPVersion
()
const
;
126
128
131
DLLEXPORT
void
setHTTP11
(
bool
h11);
132
134
DLLEXPORT
bool
isHTTP11
()
const
;
135
137
141
DLLEXPORT
int
setURL
(
const
char
*url,
ExceptionSink
*xsink);
142
144
147
DLLEXPORT
QoreStringNode
*
getURL
();
148
150
154
DLLEXPORT
void
setUserPassword
(
const
char
*user,
const
char
*pass);
155
157
DLLEXPORT
void
clearUserPassword
();
158
160
164
DLLEXPORT
int
setProxyURL
(
const
char
*proxy,
ExceptionSink
*xsink);
165
167
170
DLLEXPORT
QoreStringNode
*
getProxyURL
();
171
173
DLLEXPORT
void
clearProxyURL
();
174
176
180
DLLEXPORT
void
setProxyUserPassword
(
const
char
*user,
const
char
*pass);
181
183
DLLEXPORT
void
clearProxyUserPassword
();
184
186
DLLEXPORT
void
setSecure
(
bool
is_secure);
187
189
DLLEXPORT
bool
isSecure
()
const
;
190
192
DLLEXPORT
void
setProxySecure
(
bool
is_secure);
193
195
DLLEXPORT
bool
isProxySecure
()
const
;
196
198
DLLEXPORT
void
setMaxRedirects
(
int
max);
199
201
DLLEXPORT
int
getMaxRedirects
()
const
;
202
204
DLLEXPORT
long
verifyPeerCertificate
();
205
207
210
DLLEXPORT
const
char
*
getSSLCipherName
();
211
213
216
DLLEXPORT
const
char
*
getSSLCipherVersion
();
217
219
221
DLLEXPORT
int
connect
(
ExceptionSink
*xsink);
222
224
DLLEXPORT
void
disconnect
();
225
227
238
DLLEXPORT
QoreHashNode
*
send
(
const
char
*meth,
const
char
*path,
const
QoreHashNode
*headers,
const
void
*data,
unsigned
size,
bool
getbody,
QoreHashNode
*info,
ExceptionSink
*xsink);
239
241
248
DLLEXPORT
AbstractQoreNode
*
get
(
const
char
*path,
const
QoreHashNode
*headers,
QoreHashNode
*info,
ExceptionSink
*xsink);
249
251
257
DLLEXPORT
QoreHashNode
*
head
(
const
char
*path,
const
QoreHashNode
*headers,
QoreHashNode
*info,
ExceptionSink
*xsink);
258
260
269
DLLEXPORT
AbstractQoreNode
*
post
(
const
char
*path,
const
QoreHashNode
*headers,
const
void
*data,
unsigned
size,
QoreHashNode
*info,
ExceptionSink
*xsink);
270
272
276
DLLEXPORT
void
setDefaultHeaderValue
(
const
char
*header,
const
char
*val);
277
278
using
AbstractPrivateData::deref
;
280
283
DLLEXPORT
virtual
void
deref
(
ExceptionSink
*xsink);
284
286
289
DLLEXPORT
void
setConnectTimeout
(
int
ms);
290
292
295
DLLEXPORT
int
getConnectTimeout
()
const
;
296
298
307
DLLEXPORT
int
setNoDelay
(
bool
nodelay);
308
310
DLLEXPORT
void
setEventQueue
(Queue *cbq,
ExceptionSink
*xsink);
311
313
DLLEXPORT
bool
getNoDelay
()
const
;
314
316
DLLEXPORT
bool
isConnected
()
const
;
317
319
330
DLLEXPORT
QoreHashNode
*
getPeerInfo
(
ExceptionSink
* xsink)
const
;
331
333
344
DLLEXPORT
QoreHashNode
*
getSocketInfo
(
ExceptionSink
* xsink)
const
;
345
346
DLLLOCAL
static
void
static_init();
347
348
DLLLOCAL
void
cleanup(
ExceptionSink
*xsink);
349
};
350
351
#endif