-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathivrHttp.h
More file actions
123 lines (103 loc) · 2.84 KB
/
ivrHttp.h
File metadata and controls
123 lines (103 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#pragma once
#ifdef MOCKUP
#define ILOG fprintf
#define IL_ERR stderr
#define IL_DB1 stderr
#define IL_DB4 stderr
#endif
static const char XMLNS_TAG[] = "xmlns";
static const char XML_CONTENT_TYPE[] = "Content-Type: application/xml";
static const char JSON_CONTENT_TYPE[] = "Content-Type: application/json";
typedef enum {XML = 1, JSON, NO_BODY} HTTPContentType;
typedef enum {GET = 1, POST} HTTPMethodType;
#ifdef __cplusplus
#include <map>
class IHttpClient
{
public:
IHttpClient();
virtual ~IHttpClient();
virtual bool postData(const char *urlData,
const char *contentType,
const char *requestData,
char *responseData,
int responseLength,
char *errorMessage,
int errorLength,
int *httpStatusCode) = 0;
virtual bool getData(const char *urlData,
const char *queryData,
const char *contentType,
char *responseData,
int responseLength,
char *errorMessage,
int errorLength,
int *httpStatusCode) = 0;
string getStrContentType(HTTPContentType t);
protected:
map< HTTPContentType, string > contTypes;
};
class IvrHTTPTest : public IHttpClient
{
public:
IvrHTTPTest() {};
virtual ~IvrHTTPTest() {};
bool postData(const char *urlData,
const char *contentType,
const char *requestData,
char *responseData,
int responseLength,
char *errorMessage,
int errorLength,
int *httpStatusCode);
bool getData(const char *urlData,
const char *queryData,
const char *contentType,
char *responseData,
int responseLength,
char *errorMessage,
int errorLength,
int *httpStatusCode);
};
class IvrHTTPClient : public IHttpClient
{
public:
IvrHTTPClient() {};
virtual ~IvrHTTPClient() {};
bool postData(const char *urlData,
const char *contentType,
const char *requestData,
char *responseData,
int responseLength,
char *errorMessage,
int errorLength,
int *httpStatusCode);
bool getData(const char *urlData,
const char *queryData,
const char *contentType,
char *responseData,
int responseLength,
char *errorMessage,
int errorLength,
int *httpStatusCode);
};
#endif
#ifdef __cplusplus
extern "C"
{
#endif
void* getClientObj();
void* getClientMoc();
void destroyClientObj( void *clientObj );
int httpRequest( void* clientObj,
HTTPContentType contentType,
HTTPMethodType methodType,
const char *url,
const char *queryData,
char *responseData,
int responseLength,
char *errorMessage,
int errorLength);
#ifdef __cplusplus
}
#endif