HTTPS Client for MiniTLS-GPL

Dependents:   MiniTLS-HTTPS-Example

Committer:
MiniTLS
Date:
Tue Jun 10 14:23:22 2014 +0000
Revision:
0:62a4a8ec4ab5
Initial commit

Who changed what in which revision?

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