Leest de waarde van een sensor binnen een maakt deze beschikbaar via internet

Dependencies:   NTPClient_NetServices mbed

Committer:
hendrikvincent
Date:
Mon Dec 02 09:01:23 2013 +0000
Revision:
0:05ccbd4f84f1
eerste programma;

Who changed what in which revision?

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