u-blox modem HTTP client test

Dependencies:   UbloxUSBModem mbed

Committer:
bogdanm
Date:
Fri Oct 18 21:05:40 2013 +0300
Revision:
1:0112fc45285a
Child:
6:d17e425e9425
Initial release of the test program

Who changed what in which revision?

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