Multi-Hackers / AxedaWrapper

Dependents:   axeda_wrapper_dev MTS_Axeda_Example

Committer:
mfiore
Date:
Sat Jan 04 05:07:10 2014 +0000
Revision:
5:dd1e00e3eba5
added modified HTTPClient library; added MbedJSONValue library

Who changed what in which revision?

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