Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
HTTPTransport.h@30:bf56ef794ba6, 2014-02-28 (annotated)
- Committer:
- ansond
- Date:
- Fri Feb 28 05:00:52 2014 +0000
- Revision:
- 30:bf56ef794ba6
- Child:
- 37:1588ba3af6d1
updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 30:bf56ef794ba6 | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 30:bf56ef794ba6 | 2 | * |
ansond | 30:bf56ef794ba6 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 30:bf56ef794ba6 | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 30:bf56ef794ba6 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 30:bf56ef794ba6 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 30:bf56ef794ba6 | 7 | * furnished to do so, subject to the following conditions: |
ansond | 30:bf56ef794ba6 | 8 | * |
ansond | 30:bf56ef794ba6 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 30:bf56ef794ba6 | 10 | * substantial portions of the Software. |
ansond | 30:bf56ef794ba6 | 11 | * |
ansond | 30:bf56ef794ba6 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 30:bf56ef794ba6 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 30:bf56ef794ba6 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 30:bf56ef794ba6 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 30:bf56ef794ba6 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 30:bf56ef794ba6 | 17 | */ |
ansond | 30:bf56ef794ba6 | 18 | |
ansond | 30:bf56ef794ba6 | 19 | #ifndef ___HTTPTRANSPORT_H_ |
ansond | 30:bf56ef794ba6 | 20 | #define ___HTTPTRANSPORT_H_ |
ansond | 30:bf56ef794ba6 | 21 | |
ansond | 30:bf56ef794ba6 | 22 | // Base Class |
ansond | 30:bf56ef794ba6 | 23 | #include "Transport.h" |
ansond | 30:bf56ef794ba6 | 24 | |
ansond | 30:bf56ef794ba6 | 25 | // HTTP Client Library Support |
ansond | 30:bf56ef794ba6 | 26 | #include "HTTPClient.h" |
ansond | 30:bf56ef794ba6 | 27 | |
ansond | 30:bf56ef794ba6 | 28 | class HTTPTransport : public Transport { |
ansond | 30:bf56ef794ba6 | 29 | private: |
ansond | 30:bf56ef794ba6 | 30 | HTTPClient *m_http; |
ansond | 30:bf56ef794ba6 | 31 | char m_url_buffer[IOC_REST_URL_LEN+1]; |
ansond | 30:bf56ef794ba6 | 32 | |
ansond | 30:bf56ef794ba6 | 33 | public: |
ansond | 30:bf56ef794ba6 | 34 | HTTPTransport(ErrorHandler *error_handler,void *endpoint); |
ansond | 30:bf56ef794ba6 | 35 | virtual ~HTTPTransport(); |
ansond | 30:bf56ef794ba6 | 36 | |
ansond | 30:bf56ef794ba6 | 37 | bool httpGet(char *url,char *result,int result_length); |
ansond | 30:bf56ef794ba6 | 38 | bool httpPut(char *url,char *data,int data_length,char *result,int result_length); |
ansond | 30:bf56ef794ba6 | 39 | bool httpPost(char *url,char *data,int data_length,char *result,int result_length); |
ansond | 30:bf56ef794ba6 | 40 | bool httpDelete(char *url,char *data,int data_length); |
ansond | 30:bf56ef794ba6 | 41 | |
ansond | 30:bf56ef794ba6 | 42 | virtual bool loadEndpoint(char *data,int data_length,char *result,int result_length); |
ansond | 30:bf56ef794ba6 | 43 | virtual bool updateEndpoint(int ioc_id,char *data,int data_length,char *result,int result_length); |
ansond | 30:bf56ef794ba6 | 44 | |
ansond | 30:bf56ef794ba6 | 45 | virtual bool connect(); |
ansond | 30:bf56ef794ba6 | 46 | virtual bool disconnect(); |
ansond | 30:bf56ef794ba6 | 47 | |
ansond | 30:bf56ef794ba6 | 48 | private: |
ansond | 30:bf56ef794ba6 | 49 | char *createIOCLoadURL(); |
ansond | 30:bf56ef794ba6 | 50 | char *packageData(char *verb,char *data,int ioc_id); |
ansond | 30:bf56ef794ba6 | 51 | char *createIOCUpdateURL(int ioc_id); |
ansond | 30:bf56ef794ba6 | 52 | char *createIOCUpdateURL(int ioc_id,bool useRedirector); |
ansond | 30:bf56ef794ba6 | 53 | }; |
ansond | 30:bf56ef794ba6 | 54 | |
ansond | 30:bf56ef794ba6 | 55 | #endif // ___HTTPTRANSPORT_H_ |