User | Revision | Line number | New contents of line |
slowness |
0:58c3d014a4e7
|
1
|
|
slowness |
0:58c3d014a4e7
|
2
|
/*
|
slowness |
0:58c3d014a4e7
|
3
|
Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
|
slowness |
0:58c3d014a4e7
|
4
|
|
slowness |
0:58c3d014a4e7
|
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
slowness |
0:58c3d014a4e7
|
6
|
of this software and associated documentation files (the "Software"), to deal
|
slowness |
0:58c3d014a4e7
|
7
|
in the Software without restriction, including without limitation the rights
|
slowness |
0:58c3d014a4e7
|
8
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
slowness |
0:58c3d014a4e7
|
9
|
copies of the Software, and to permit persons to whom the Software is
|
slowness |
0:58c3d014a4e7
|
10
|
furnished to do so, subject to the following conditions:
|
slowness |
0:58c3d014a4e7
|
11
|
|
slowness |
0:58c3d014a4e7
|
12
|
The above copyright notice and this permission notice shall be included in
|
slowness |
0:58c3d014a4e7
|
13
|
all copies or substantial portions of the Software.
|
slowness |
0:58c3d014a4e7
|
14
|
|
slowness |
0:58c3d014a4e7
|
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
slowness |
0:58c3d014a4e7
|
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
slowness |
0:58c3d014a4e7
|
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
slowness |
0:58c3d014a4e7
|
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
slowness |
0:58c3d014a4e7
|
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
slowness |
0:58c3d014a4e7
|
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
slowness |
0:58c3d014a4e7
|
21
|
THE SOFTWARE.
|
slowness |
0:58c3d014a4e7
|
22
|
*/
|
slowness |
0:58c3d014a4e7
|
23
|
|
slowness |
0:58c3d014a4e7
|
24
|
/** \file
|
slowness |
0:58c3d014a4e7
|
25
|
HTTP Client header file
|
slowness |
0:58c3d014a4e7
|
26
|
*/
|
slowness |
0:58c3d014a4e7
|
27
|
|
slowness |
0:58c3d014a4e7
|
28
|
#ifndef HTTP_CLIENT_H
|
slowness |
0:58c3d014a4e7
|
29
|
#define HTTP_CLIENT_H
|
slowness |
0:58c3d014a4e7
|
30
|
|
slowness |
0:58c3d014a4e7
|
31
|
class HTTPData;
|
slowness |
0:58c3d014a4e7
|
32
|
|
slowness |
0:58c3d014a4e7
|
33
|
#include "core/net.h"
|
slowness |
0:58c3d014a4e7
|
34
|
#include "api/TCPSocket.h"
|
slowness |
0:58c3d014a4e7
|
35
|
#include "api/DNSRequest.h"
|
slowness |
0:58c3d014a4e7
|
36
|
#include "HTTPData.h"
|
slowness |
0:58c3d014a4e7
|
37
|
#include "mbed.h"
|
slowness |
0:58c3d014a4e7
|
38
|
|
slowness |
0:58c3d014a4e7
|
39
|
#include <string>
|
slowness |
0:58c3d014a4e7
|
40
|
using std::string;
|
slowness |
0:58c3d014a4e7
|
41
|
|
slowness |
0:58c3d014a4e7
|
42
|
#include <map>
|
slowness |
0:58c3d014a4e7
|
43
|
using std::map;
|
slowness |
0:58c3d014a4e7
|
44
|
|
slowness |
0:58c3d014a4e7
|
45
|
///HTTP client results
|
slowness |
0:58c3d014a4e7
|
46
|
enum HTTPResult
|
slowness |
0:58c3d014a4e7
|
47
|
{
|
slowness |
0:58c3d014a4e7
|
48
|
HTTP_OK, ///<Success
|
slowness |
0:58c3d014a4e7
|
49
|
HTTP_PROCESSING, ///<Processing
|
slowness |
0:58c3d014a4e7
|
50
|
HTTP_PARSE, ///<URI Parse error
|
slowness |
0:58c3d014a4e7
|
51
|
HTTP_DNS, ///<Could not resolve name
|
slowness |
0:58c3d014a4e7
|
52
|
HTTP_PRTCL, ///<Protocol error
|
slowness |
0:58c3d014a4e7
|
53
|
HTTP_NOTFOUND, ///<HTTP 404 Error
|
slowness |
0:58c3d014a4e7
|
54
|
HTTP_REFUSED, ///<HTTP 403 Error
|
slowness |
0:58c3d014a4e7
|
55
|
HTTP_ERROR, ///<HTTP xxx error
|
slowness |
0:58c3d014a4e7
|
56
|
HTTP_TIMEOUT, ///<Connection timeout
|
slowness |
0:58c3d014a4e7
|
57
|
HTTP_CONN ///<Connection error
|
slowness |
0:58c3d014a4e7
|
58
|
};
|
slowness |
0:58c3d014a4e7
|
59
|
|
slowness |
0:58c3d014a4e7
|
60
|
#include "core/netservice.h"
|
slowness |
0:58c3d014a4e7
|
61
|
|
slowness |
0:58c3d014a4e7
|
62
|
///A simple HTTP Client
|
slowness |
0:58c3d014a4e7
|
63
|
/**
|
slowness |
0:58c3d014a4e7
|
64
|
The HTTPClient is composed of:
|
slowness |
0:58c3d014a4e7
|
65
|
- The actual client (HTTPClient)
|
slowness |
0:58c3d014a4e7
|
66
|
- Classes that act as a data repository, each of which deriving from the HTTPData class (HTTPText for short text content, HTTPFile for file I/O, HTTPMap for key/value pairs, and HTTPStream for streaming purposes)
|
slowness |
0:58c3d014a4e7
|
67
|
*/
|
slowness |
0:58c3d014a4e7
|
68
|
class HTTPClient : protected NetService
|
slowness |
0:58c3d014a4e7
|
69
|
{
|
slowness |
0:58c3d014a4e7
|
70
|
public:
|
slowness |
0:58c3d014a4e7
|
71
|
///Instantiates the HTTP client
|
slowness |
0:58c3d014a4e7
|
72
|
HTTPClient();
|
slowness |
0:58c3d014a4e7
|
73
|
virtual ~HTTPClient();
|
slowness |
0:58c3d014a4e7
|
74
|
|
slowness |
0:58c3d014a4e7
|
75
|
///Provides a basic authentification feature (Base64 encoded username and password)
|
slowness |
0:58c3d014a4e7
|
76
|
void basicAuth(const char* user, const char* password); //Basic Authentification
|
slowness |
0:58c3d014a4e7
|
77
|
|
slowness |
0:58c3d014a4e7
|
78
|
//High Level setup functions
|
slowness |
0:58c3d014a4e7
|
79
|
///Executes a GET Request (blocking)
|
slowness |
0:58c3d014a4e7
|
80
|
/**
|
slowness |
0:58c3d014a4e7
|
81
|
Executes a GET request on the URI uri
|
slowness |
0:58c3d014a4e7
|
82
|
@param uri : URI on which to execute the request
|
slowness |
0:58c3d014a4e7
|
83
|
@param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
|
slowness |
0:58c3d014a4e7
|
84
|
Blocks until completion
|
slowness |
0:58c3d014a4e7
|
85
|
*/
|
slowness |
0:58c3d014a4e7
|
86
|
HTTPResult get(const char* uri, HTTPData* pDataIn); //Blocking
|
slowness |
0:58c3d014a4e7
|
87
|
|
slowness |
0:58c3d014a4e7
|
88
|
///Executes a GET Request (non blocking)
|
slowness |
0:58c3d014a4e7
|
89
|
/**
|
slowness |
0:58c3d014a4e7
|
90
|
Executes a GET request on the URI uri
|
slowness |
0:58c3d014a4e7
|
91
|
@param uri : URI on which to execute the request
|
slowness |
0:58c3d014a4e7
|
92
|
@param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
|
slowness |
0:58c3d014a4e7
|
93
|
@param pMethod : callback function
|
slowness |
0:58c3d014a4e7
|
94
|
The function returns immediately and calls the callback on completion or error
|
slowness |
0:58c3d014a4e7
|
95
|
*/
|
slowness |
0:58c3d014a4e7
|
96
|
HTTPResult get(const char* uri, HTTPData* pDataIn, void (*pMethod)(HTTPResult)); //Non blocking
|
slowness |
0:58c3d014a4e7
|
97
|
|
slowness |
0:58c3d014a4e7
|
98
|
///Executes a GET Request (non blocking)
|
slowness |
0:58c3d014a4e7
|
99
|
/**
|
slowness |
0:58c3d014a4e7
|
100
|
Executes a GET request on the URI uri
|
slowness |
0:58c3d014a4e7
|
101
|
@param uri : URI on which to execute the request
|
slowness |
0:58c3d014a4e7
|
102
|
@param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
|
slowness |
0:58c3d014a4e7
|
103
|
@param pItem : instance of class on which to execute the callback method
|
slowness |
0:58c3d014a4e7
|
104
|
@param pMethod : callback method
|
slowness |
0:58c3d014a4e7
|
105
|
The function returns immediately and calls the callback on completion or error
|
slowness |
0:58c3d014a4e7
|
106
|
*/
|
slowness |
0:58c3d014a4e7
|
107
|
template<class T>
|
slowness |
0:58c3d014a4e7
|
108
|
HTTPResult get(const char* uri, HTTPData* pDataIn, T* pItem, void (T::*pMethod)(HTTPResult)) //Non blocking
|
slowness |
0:58c3d014a4e7
|
109
|
{
|
slowness |
0:58c3d014a4e7
|
110
|
setOnResult(pItem, pMethod);
|
slowness |
0:58c3d014a4e7
|
111
|
doGet(uri, pDataIn);
|
slowness |
0:58c3d014a4e7
|
112
|
return HTTP_PROCESSING;
|
slowness |
0:58c3d014a4e7
|
113
|
}
|
slowness |
0:58c3d014a4e7
|
114
|
|
slowness |
0:58c3d014a4e7
|
115
|
///Executes a POST Request (blocking)
|
slowness |
0:58c3d014a4e7
|
116
|
/**
|
slowness |
0:58c3d014a4e7
|
117
|
Executes a POST request on the URI uri
|
slowness |
0:58c3d014a4e7
|
118
|
@param uri : URI on which to execute the request
|
slowness |
0:58c3d014a4e7
|
119
|
@param dataOut : a HTTPData instance that contains the data that will be posted
|
slowness |
0:58c3d014a4e7
|
120
|
@param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
|
slowness |
0:58c3d014a4e7
|
121
|
Blocks until completion
|
slowness |
0:58c3d014a4e7
|
122
|
*/
|
slowness |
0:58c3d014a4e7
|
123
|
HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn); //Blocking
|
slowness |
0:58c3d014a4e7
|
124
|
|
slowness |
0:58c3d014a4e7
|
125
|
///Executes a POST Request (non blocking)
|
slowness |
0:58c3d014a4e7
|
126
|
/**
|
slowness |
0:58c3d014a4e7
|
127
|
Executes a POST request on the URI uri
|
slowness |
0:58c3d014a4e7
|
128
|
@param uri : URI on which to execute the request
|
slowness |
0:58c3d014a4e7
|
129
|
@param dataOut : a HTTPData instance that contains the data that will be posted
|
slowness |
0:58c3d014a4e7
|
130
|
@param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
|
slowness |
0:58c3d014a4e7
|
131
|
@param pMethod : callback function
|
slowness |
0:58c3d014a4e7
|
132
|
The function returns immediately and calls the callback on completion or error
|
slowness |
0:58c3d014a4e7
|
133
|
*/
|
slowness |
0:58c3d014a4e7
|
134
|
HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn, void (*pMethod)(HTTPResult)); //Non blocking
|
slowness |
0:58c3d014a4e7
|
135
|
|
slowness |
0:58c3d014a4e7
|
136
|
///Executes a POST Request (non blocking)
|
slowness |
0:58c3d014a4e7
|
137
|
/**
|
slowness |
0:58c3d014a4e7
|
138
|
Executes a POST request on the URI uri
|
slowness |
0:58c3d014a4e7
|
139
|
@param uri : URI on which to execute the request
|
slowness |
0:58c3d014a4e7
|
140
|
@param dataOut : a HTTPData instance that contains the data that will be posted
|
slowness |
0:58c3d014a4e7
|
141
|
@param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
|
slowness |
0:58c3d014a4e7
|
142
|
@param pItem : instance of class on which to execute the callback method
|
slowness |
0:58c3d014a4e7
|
143
|
@param pMethod : callback method
|
slowness |
0:58c3d014a4e7
|
144
|
The function returns immediately and calls the callback on completion or error
|
slowness |
0:58c3d014a4e7
|
145
|
*/
|
slowness |
0:58c3d014a4e7
|
146
|
template<class T>
|
slowness |
0:58c3d014a4e7
|
147
|
HTTPResult post(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn, T* pItem, void (T::*pMethod)(HTTPResult)) //Non blocking
|
slowness |
0:58c3d014a4e7
|
148
|
{
|
slowness |
0:58c3d014a4e7
|
149
|
setOnResult(pItem, pMethod);
|
slowness |
0:58c3d014a4e7
|
150
|
doPost(uri, dataOut, pDataIn);
|
slowness |
0:58c3d014a4e7
|
151
|
return HTTP_PROCESSING;
|
slowness |
0:58c3d014a4e7
|
152
|
}
|
slowness |
0:58c3d014a4e7
|
153
|
|
slowness |
0:58c3d014a4e7
|
154
|
///Executes a GET Request (non blocking)
|
slowness |
0:58c3d014a4e7
|
155
|
/**
|
slowness |
0:58c3d014a4e7
|
156
|
Executes a GET request on the URI uri
|
slowness |
0:58c3d014a4e7
|
157
|
@param uri : URI on which to execute the request
|
slowness |
0:58c3d014a4e7
|
158
|
@param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
|
slowness |
0:58c3d014a4e7
|
159
|
The function returns immediately and calls the previously set callback on completion or error
|
slowness |
0:58c3d014a4e7
|
160
|
*/
|
slowness |
0:58c3d014a4e7
|
161
|
void doGet(const char* uri, HTTPData* pDataIn);
|
slowness |
0:58c3d014a4e7
|
162
|
|
slowness |
0:58c3d014a4e7
|
163
|
///Executes a POST Request (non blocking)
|
slowness |
0:58c3d014a4e7
|
164
|
/**
|
slowness |
0:58c3d014a4e7
|
165
|
Executes a POST request on the URI uri
|
slowness |
0:58c3d014a4e7
|
166
|
@param uri : URI on which to execute the request
|
slowness |
0:58c3d014a4e7
|
167
|
@param dataOut : a HTTPData instance that contains the data that will be posted
|
slowness |
0:58c3d014a4e7
|
168
|
@param pDataIn : pointer to an HTTPData instance that will collect the data returned by the request, can be NULL
|
slowness |
0:58c3d014a4e7
|
169
|
@param pMethod : callback function
|
slowness |
0:58c3d014a4e7
|
170
|
The function returns immediately and calls the previously set callback on completion or error
|
slowness |
0:58c3d014a4e7
|
171
|
*/
|
slowness |
0:58c3d014a4e7
|
172
|
void doPost(const char* uri, const HTTPData& dataOut, HTTPData* pDataIn);
|
slowness |
0:58c3d014a4e7
|
173
|
|
slowness |
0:58c3d014a4e7
|
174
|
///Setups the result callback
|
slowness |
0:58c3d014a4e7
|
175
|
/**
|
slowness |
0:58c3d014a4e7
|
176
|
@param pMethod : callback function
|
slowness |
0:58c3d014a4e7
|
177
|
*/
|
slowness |
0:58c3d014a4e7
|
178
|
void setOnResult( void (*pMethod)(HTTPResult) );
|
slowness |
0:58c3d014a4e7
|
179
|
|
slowness |
0:58c3d014a4e7
|
180
|
///Setups the result callback
|
slowness |
0:58c3d014a4e7
|
181
|
/**
|
slowness |
0:58c3d014a4e7
|
182
|
@param pItem : instance of class on which to execute the callback method
|
slowness |
0:58c3d014a4e7
|
183
|
@param pMethod : callback method
|
slowness |
0:58c3d014a4e7
|
184
|
*/
|
slowness |
0:58c3d014a4e7
|
185
|
class CDummy;
|
slowness |
0:58c3d014a4e7
|
186
|
template<class T>
|
slowness |
0:58c3d014a4e7
|
187
|
void setOnResult( T* pItem, void (T::*pMethod)(HTTPResult) )
|
slowness |
0:58c3d014a4e7
|
188
|
{
|
slowness |
0:58c3d014a4e7
|
189
|
m_pCb = NULL;
|
slowness |
0:58c3d014a4e7
|
190
|
m_pCbItem = (CDummy*) pItem;
|
slowness |
0:58c3d014a4e7
|
191
|
m_pCbMeth = (void (CDummy::*)(HTTPResult)) pMethod;
|
slowness |
0:58c3d014a4e7
|
192
|
}
|
slowness |
0:58c3d014a4e7
|
193
|
|
slowness |
0:58c3d014a4e7
|
194
|
///Setups timeout
|
slowness |
0:58c3d014a4e7
|
195
|
/**
|
slowness |
0:58c3d014a4e7
|
196
|
@param ms : time of connection inactivity in ms after which the request should timeout
|
slowness |
0:58c3d014a4e7
|
197
|
*/
|
slowness |
0:58c3d014a4e7
|
198
|
void setTimeout(int ms);
|
slowness |
0:58c3d014a4e7
|
199
|
|
slowness |
0:58c3d014a4e7
|
200
|
virtual void poll(); //Called by NetServices
|
slowness |
0:58c3d014a4e7
|
201
|
|
slowness |
0:58c3d014a4e7
|
202
|
///Gets last request's HTTP response code
|
slowness |
0:58c3d014a4e7
|
203
|
/**
|
slowness |
0:58c3d014a4e7
|
204
|
@return The HTTP response code of the last request
|
slowness |
0:58c3d014a4e7
|
205
|
*/
|
slowness |
0:58c3d014a4e7
|
206
|
int getHTTPResponseCode();
|
slowness |
0:58c3d014a4e7
|
207
|
|
slowness |
0:58c3d014a4e7
|
208
|
///Sets a specific request header
|
slowness |
0:58c3d014a4e7
|
209
|
void setRequestHeader(const string& header, const string& value);
|
slowness |
0:58c3d014a4e7
|
210
|
|
slowness |
0:58c3d014a4e7
|
211
|
///Gets a response header
|
slowness |
0:58c3d014a4e7
|
212
|
string& getResponseHeader(const string& header);
|
slowness |
0:58c3d014a4e7
|
213
|
|
slowness |
0:58c3d014a4e7
|
214
|
///Clears request headers
|
slowness |
0:58c3d014a4e7
|
215
|
void resetRequestHeaders();
|
slowness |
0:58c3d014a4e7
|
216
|
|
slowness |
0:58c3d014a4e7
|
217
|
protected:
|
slowness |
0:58c3d014a4e7
|
218
|
void resetTimeout();
|
slowness |
0:58c3d014a4e7
|
219
|
|
slowness |
0:58c3d014a4e7
|
220
|
void init();
|
slowness |
0:58c3d014a4e7
|
221
|
void close();
|
slowness |
0:58c3d014a4e7
|
222
|
|
slowness |
0:58c3d014a4e7
|
223
|
void setup(const char* uri, HTTPData* pDataOut, HTTPData* pDataIn); //Setup request, make DNS Req if necessary
|
slowness |
0:58c3d014a4e7
|
224
|
void connect(); //Start Connection
|
slowness |
0:58c3d014a4e7
|
225
|
|
slowness |
0:58c3d014a4e7
|
226
|
int tryRead(); //Read data and try to feed output
|
slowness |
0:58c3d014a4e7
|
227
|
void readData(); //Data has been read
|
slowness |
0:58c3d014a4e7
|
228
|
void writeData(); //Data has been written & buf is free
|
slowness |
0:58c3d014a4e7
|
229
|
|
slowness |
0:58c3d014a4e7
|
230
|
void onTCPSocketEvent(TCPSocketEvent e);
|
slowness |
0:58c3d014a4e7
|
231
|
void onDNSReply(DNSReply r);
|
slowness |
0:58c3d014a4e7
|
232
|
void onResult(HTTPResult r); //Called when exchange completed or on failure
|
slowness |
0:58c3d014a4e7
|
233
|
void onTimeout(); //Connection has timed out
|
slowness |
0:58c3d014a4e7
|
234
|
|
slowness |
0:58c3d014a4e7
|
235
|
private:
|
slowness |
0:58c3d014a4e7
|
236
|
HTTPResult blockingProcess(); //Called in blocking mode, calls Net::poll() until return code is available
|
slowness |
0:58c3d014a4e7
|
237
|
|
slowness |
0:58c3d014a4e7
|
238
|
bool readHeaders(); //Called first when receiving data
|
slowness |
0:58c3d014a4e7
|
239
|
bool writeHeaders(); //Called to create req
|
slowness |
0:58c3d014a4e7
|
240
|
int readLine(char* str, int maxLen, bool* pIncomplete = NULL);
|
slowness |
0:58c3d014a4e7
|
241
|
|
slowness |
0:58c3d014a4e7
|
242
|
enum HTTP_METH
|
slowness |
0:58c3d014a4e7
|
243
|
{
|
slowness |
0:58c3d014a4e7
|
244
|
HTTP_GET,
|
slowness |
0:58c3d014a4e7
|
245
|
HTTP_POST,
|
slowness |
0:58c3d014a4e7
|
246
|
HTTP_HEAD
|
slowness |
0:58c3d014a4e7
|
247
|
};
|
slowness |
0:58c3d014a4e7
|
248
|
|
slowness |
0:58c3d014a4e7
|
249
|
HTTP_METH m_meth;
|
slowness |
0:58c3d014a4e7
|
250
|
|
slowness |
0:58c3d014a4e7
|
251
|
CDummy* m_pCbItem;
|
slowness |
0:58c3d014a4e7
|
252
|
void (CDummy::*m_pCbMeth)(HTTPResult);
|
slowness |
0:58c3d014a4e7
|
253
|
|
slowness |
0:58c3d014a4e7
|
254
|
void (*m_pCb)(HTTPResult);
|
slowness |
0:58c3d014a4e7
|
255
|
|
slowness |
0:58c3d014a4e7
|
256
|
TCPSocket* m_pTCPSocket;
|
slowness |
0:58c3d014a4e7
|
257
|
map<string, string> m_reqHeaders;
|
slowness |
0:58c3d014a4e7
|
258
|
map<string, string> m_respHeaders;
|
slowness |
0:58c3d014a4e7
|
259
|
|
slowness |
0:58c3d014a4e7
|
260
|
Timer m_watchdog;
|
slowness |
0:58c3d014a4e7
|
261
|
int m_timeout;
|
slowness |
0:58c3d014a4e7
|
262
|
|
slowness |
0:58c3d014a4e7
|
263
|
DNSRequest* m_pDnsReq;
|
slowness |
0:58c3d014a4e7
|
264
|
|
slowness |
0:58c3d014a4e7
|
265
|
Host m_server;
|
slowness |
0:58c3d014a4e7
|
266
|
string m_path;
|
slowness |
0:58c3d014a4e7
|
267
|
|
slowness |
0:58c3d014a4e7
|
268
|
bool m_closed;
|
slowness |
0:58c3d014a4e7
|
269
|
|
slowness |
0:58c3d014a4e7
|
270
|
enum HTTPStep
|
slowness |
0:58c3d014a4e7
|
271
|
{
|
slowness |
0:58c3d014a4e7
|
272
|
// HTTP_INIT,
|
slowness |
0:58c3d014a4e7
|
273
|
HTTP_WRITE_HEADERS,
|
slowness |
0:58c3d014a4e7
|
274
|
HTTP_WRITE_DATA,
|
slowness |
0:58c3d014a4e7
|
275
|
HTTP_READ_HEADERS,
|
slowness |
0:58c3d014a4e7
|
276
|
HTTP_READ_DATA,
|
slowness |
0:58c3d014a4e7
|
277
|
HTTP_READ_DATA_INCOMPLETE,
|
slowness |
0:58c3d014a4e7
|
278
|
HTTP_DONE,
|
slowness |
0:58c3d014a4e7
|
279
|
HTTP_CLOSED
|
slowness |
0:58c3d014a4e7
|
280
|
};
|
slowness |
0:58c3d014a4e7
|
281
|
|
slowness |
0:58c3d014a4e7
|
282
|
HTTPStep m_state;
|
slowness |
0:58c3d014a4e7
|
283
|
|
slowness |
0:58c3d014a4e7
|
284
|
HTTPData* m_pDataOut;
|
slowness |
0:58c3d014a4e7
|
285
|
HTTPData* m_pDataIn;
|
slowness |
0:58c3d014a4e7
|
286
|
|
slowness |
0:58c3d014a4e7
|
287
|
bool m_dataChunked; //Data is encoded as chunks
|
slowness |
0:58c3d014a4e7
|
288
|
int m_dataPos; //Position in data
|
slowness |
0:58c3d014a4e7
|
289
|
int m_dataLen; //Data length
|
slowness |
0:58c3d014a4e7
|
290
|
char* m_buf;
|
slowness |
0:58c3d014a4e7
|
291
|
char* m_pBufRemaining; //Remaining
|
slowness |
0:58c3d014a4e7
|
292
|
int m_bufRemainingLen; //Data length in m_pBufRemaining
|
slowness |
0:58c3d014a4e7
|
293
|
|
slowness |
0:58c3d014a4e7
|
294
|
int m_httpResponseCode;
|
slowness |
0:58c3d014a4e7
|
295
|
|
slowness |
0:58c3d014a4e7
|
296
|
HTTPResult m_blockingResult; //Result if blocking mode
|
slowness |
0:58c3d014a4e7
|
297
|
|
slowness |
0:58c3d014a4e7
|
298
|
};
|
slowness |
0:58c3d014a4e7
|
299
|
|
slowness |
0:58c3d014a4e7
|
300
|
//Including data containers here for more convenience
|
slowness |
0:58c3d014a4e7
|
301
|
#include "data/HTTPFile.h"
|
slowness |
0:58c3d014a4e7
|
302
|
#include "data/HTTPStream.h"
|
slowness |
0:58c3d014a4e7
|
303
|
#include "data/HTTPText.h"
|
slowness |
0:58c3d014a4e7
|
304
|
#include "data/HTTPMap.h"
|
slowness |
0:58c3d014a4e7
|
305
|
|
slowness |
0:58c3d014a4e7
|
306
|
#endif
|