SecureDweet is a dweet.io library that works on HTTPS protocol using SecureHttpClient library. It'll be able to fetch or listen to Dweet APIs and JSON messages.

Committer:
faheem_chaudhary
Date:
Mon Aug 22 18:37:13 2016 +0000
Revision:
0:b30bbf6fe90d
First-cut library code check-in.  No guarantees to work.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
faheem_chaudhary 0:b30bbf6fe90d 1 /*
faheem_chaudhary 0:b30bbf6fe90d 2 * HttpText.h
faheem_chaudhary 0:b30bbf6fe90d 3 *
faheem_chaudhary 0:b30bbf6fe90d 4 * Created on: Aug 16, 2016
faheem_chaudhary 0:b30bbf6fe90d 5 * Author: Faheem Inayat
faheem_chaudhary 0:b30bbf6fe90d 6 * Created for: Renesas Electronics America HQ, Santa Clara, CA, USA
faheem_chaudhary 0:b30bbf6fe90d 7 *
faheem_chaudhary 0:b30bbf6fe90d 8 * Copyright (c) 2016 Renesas Electronics America (REA) and Faheem Inayat
faheem_chaudhary 0:b30bbf6fe90d 9 */
faheem_chaudhary 0:b30bbf6fe90d 10 /* Copyright (C) 2012 mbed.org, MIT License
faheem_chaudhary 0:b30bbf6fe90d 11 *
faheem_chaudhary 0:b30bbf6fe90d 12 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
faheem_chaudhary 0:b30bbf6fe90d 13 * and associated documentation files (the "Software"), to deal in the Software without restriction,
faheem_chaudhary 0:b30bbf6fe90d 14 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
faheem_chaudhary 0:b30bbf6fe90d 15 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
faheem_chaudhary 0:b30bbf6fe90d 16 * furnished to do so, subject to the following conditions:
faheem_chaudhary 0:b30bbf6fe90d 17 *
faheem_chaudhary 0:b30bbf6fe90d 18 * The above copyright notice and this permission notice shall be included in all copies or
faheem_chaudhary 0:b30bbf6fe90d 19 * substantial portions of the Software.
faheem_chaudhary 0:b30bbf6fe90d 20 *
faheem_chaudhary 0:b30bbf6fe90d 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
faheem_chaudhary 0:b30bbf6fe90d 22 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
faheem_chaudhary 0:b30bbf6fe90d 23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
faheem_chaudhary 0:b30bbf6fe90d 24 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
faheem_chaudhary 0:b30bbf6fe90d 25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
faheem_chaudhary 0:b30bbf6fe90d 26 */
faheem_chaudhary 0:b30bbf6fe90d 27
faheem_chaudhary 0:b30bbf6fe90d 28 #ifndef HTTPTEXT_H_
faheem_chaudhary 0:b30bbf6fe90d 29 #define HTTPTEXT_H_
faheem_chaudhary 0:b30bbf6fe90d 30
faheem_chaudhary 0:b30bbf6fe90d 31 #include "IHttpDataIn.h"
faheem_chaudhary 0:b30bbf6fe90d 32 #include "IHttpDataOut.h"
faheem_chaudhary 0:b30bbf6fe90d 33
faheem_chaudhary 0:b30bbf6fe90d 34 ///This is a basic TEXT/JSON/HTML/XML implementation of IHttpDataIn and IHttpDataOut to work with SecureHttpClient
faheem_chaudhary 0:b30bbf6fe90d 35 class HttpText : public IHttpDataIn, public IHttpDataOut
faheem_chaudhary 0:b30bbf6fe90d 36 {
faheem_chaudhary 0:b30bbf6fe90d 37 public:
faheem_chaudhary 0:b30bbf6fe90d 38 /** Create an HttpText instance for output
faheem_chaudhary 0:b30bbf6fe90d 39 * @param str String to be transmitted
faheem_chaudhary 0:b30bbf6fe90d 40 */
faheem_chaudhary 0:b30bbf6fe90d 41 HttpText ( char * );
faheem_chaudhary 0:b30bbf6fe90d 42
faheem_chaudhary 0:b30bbf6fe90d 43 /** Create an HttpText instance for input
faheem_chaudhary 0:b30bbf6fe90d 44 * @param str Buffer to store the incoming string
faheem_chaudhary 0:b30bbf6fe90d 45 * @param size Size of the buffer
faheem_chaudhary 0:b30bbf6fe90d 46 */
faheem_chaudhary 0:b30bbf6fe90d 47 HttpText(char* str, size_t size);
faheem_chaudhary 0:b30bbf6fe90d 48
faheem_chaudhary 0:b30bbf6fe90d 49 virtual ~HttpText ();
faheem_chaudhary 0:b30bbf6fe90d 50
faheem_chaudhary 0:b30bbf6fe90d 51 private:
faheem_chaudhary 0:b30bbf6fe90d 52 HttpText ( const HttpText & other );
faheem_chaudhary 0:b30bbf6fe90d 53
faheem_chaudhary 0:b30bbf6fe90d 54 protected:
faheem_chaudhary 0:b30bbf6fe90d 55 //IHTTPDataIn
faheem_chaudhary 0:b30bbf6fe90d 56 virtual void readReset();
faheem_chaudhary 0:b30bbf6fe90d 57
faheem_chaudhary 0:b30bbf6fe90d 58 virtual int read(char* buf, size_t len, size_t* pReadLen);
faheem_chaudhary 0:b30bbf6fe90d 59
faheem_chaudhary 0:b30bbf6fe90d 60 virtual int getDataType(char* type, size_t maxTypeLen); //Internet media type for Content-Type header
faheem_chaudhary 0:b30bbf6fe90d 61
faheem_chaudhary 0:b30bbf6fe90d 62 virtual bool getIsChunked(); //For Transfer-Encoding header
faheem_chaudhary 0:b30bbf6fe90d 63
faheem_chaudhary 0:b30bbf6fe90d 64 virtual size_t getDataLen(); //For Content-Length header
faheem_chaudhary 0:b30bbf6fe90d 65
faheem_chaudhary 0:b30bbf6fe90d 66 //IHTTPDataOut
faheem_chaudhary 0:b30bbf6fe90d 67 virtual void writeReset();
faheem_chaudhary 0:b30bbf6fe90d 68
faheem_chaudhary 0:b30bbf6fe90d 69 virtual int write(const char* buf, size_t len);
faheem_chaudhary 0:b30bbf6fe90d 70
faheem_chaudhary 0:b30bbf6fe90d 71 virtual void setDataType(const char* type); //Internet media type from Content-Type header
faheem_chaudhary 0:b30bbf6fe90d 72
faheem_chaudhary 0:b30bbf6fe90d 73 virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
faheem_chaudhary 0:b30bbf6fe90d 74
faheem_chaudhary 0:b30bbf6fe90d 75 virtual void setDataLen(size_t len); //From Content-Length header, or if the transfer is chunked, next chunk length
faheem_chaudhary 0:b30bbf6fe90d 76
faheem_chaudhary 0:b30bbf6fe90d 77 private:
faheem_chaudhary 0:b30bbf6fe90d 78 char* m_str;
faheem_chaudhary 0:b30bbf6fe90d 79 size_t m_size;
faheem_chaudhary 0:b30bbf6fe90d 80 size_t m_pos;
faheem_chaudhary 0:b30bbf6fe90d 81 bool m_isChunked;};
faheem_chaudhary 0:b30bbf6fe90d 82
faheem_chaudhary 0:b30bbf6fe90d 83 #endif /* HTTPTEXT_H_ */
faheem_chaudhary 0:b30bbf6fe90d 84