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