HTTP Client with hardcoded authorization for supertweet proxy server.

Dependents:   twitterCoffeeMakerFinal iCoffee

Fork of HTTPClientAuthAndPathExtension by Joseph Lind

Committer:
tlisowski3
Date:
Wed Apr 23 18:37:32 2014 +0000
Revision:
18:da79dd7e9df2
Parent:
17:951bf897ba01
HTTP Client with authorization hardcoded in

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jlind6 17:951bf897ba01 1 /* IHTTPData.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 #ifndef IHTTPDATA_H
jlind6 17:951bf897ba01 21 #define IHTTPDATA_H
jlind6 17:951bf897ba01 22
jlind6 17:951bf897ba01 23 #include <cstring>
jlind6 17:951bf897ba01 24
jlind6 17:951bf897ba01 25 using std::size_t;
jlind6 17:951bf897ba01 26
jlind6 17:951bf897ba01 27 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
jlind6 17:951bf897ba01 28 class IHTTPDataOut
jlind6 17:951bf897ba01 29 {
jlind6 17:951bf897ba01 30 protected:
jlind6 17:951bf897ba01 31 friend class HTTPClient;
jlind6 17:951bf897ba01 32
jlind6 17:951bf897ba01 33 /** Reset stream to its beginning
jlind6 17:951bf897ba01 34 * Called by the HTTPClient on each new request
jlind6 17:951bf897ba01 35 */
jlind6 17:951bf897ba01 36 virtual void readReset() = 0;
jlind6 17:951bf897ba01 37
jlind6 17:951bf897ba01 38 /** Read a piece of data to be transmitted
jlind6 17:951bf897ba01 39 * @param buf Pointer to the buffer on which to copy the data
jlind6 17:951bf897ba01 40 * @param len Length of the buffer
jlind6 17:951bf897ba01 41 * @param pReadLen Pointer to the variable on which the actual copied data length will be stored
jlind6 17:951bf897ba01 42 */
jlind6 17:951bf897ba01 43 virtual int read(char* buf, size_t len, size_t* pReadLen) = 0;
jlind6 17:951bf897ba01 44
jlind6 17:951bf897ba01 45 /** Get MIME type
jlind6 17:951bf897ba01 46 * @param type Internet media type from Content-Type header
jlind6 17:951bf897ba01 47 */
jlind6 17:951bf897ba01 48 virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header
jlind6 17:951bf897ba01 49
jlind6 17:951bf897ba01 50 /** Determine whether the HTTP client should chunk the data
jlind6 17:951bf897ba01 51 * Used for Transfer-Encoding header
jlind6 17:951bf897ba01 52 */
jlind6 17:951bf897ba01 53 virtual bool getIsChunked() = 0;
jlind6 17:951bf897ba01 54
jlind6 17:951bf897ba01 55 /** If the data is not chunked, get its size
jlind6 17:951bf897ba01 56 * Used for Content-Length header
jlind6 17:951bf897ba01 57 */
jlind6 17:951bf897ba01 58 virtual size_t getDataLen() = 0;
jlind6 17:951bf897ba01 59
jlind6 17:951bf897ba01 60 };
jlind6 17:951bf897ba01 61
jlind6 17:951bf897ba01 62 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
jlind6 17:951bf897ba01 63 class IHTTPDataIn
jlind6 17:951bf897ba01 64 {
jlind6 17:951bf897ba01 65 protected:
jlind6 17:951bf897ba01 66 friend class HTTPClient;
jlind6 17:951bf897ba01 67
jlind6 17:951bf897ba01 68 /** Reset stream to its beginning
jlind6 17:951bf897ba01 69 * Called by the HTTPClient on each new request
jlind6 17:951bf897ba01 70 */
jlind6 17:951bf897ba01 71 virtual void writeReset() = 0;
jlind6 17:951bf897ba01 72
jlind6 17:951bf897ba01 73 /** Write a piece of data transmitted by the server
jlind6 17:951bf897ba01 74 * @param buf Pointer to the buffer from which to copy the data
jlind6 17:951bf897ba01 75 * @param len Length of the buffer
jlind6 17:951bf897ba01 76 */
jlind6 17:951bf897ba01 77 virtual int write(const char* buf, size_t len) = 0;
jlind6 17:951bf897ba01 78
jlind6 17:951bf897ba01 79 /** Set MIME type
jlind6 17:951bf897ba01 80 * @param type Internet media type from Content-Type header
jlind6 17:951bf897ba01 81 */
jlind6 17:951bf897ba01 82 virtual void setDataType(const char* type) = 0;
jlind6 17:951bf897ba01 83
jlind6 17:951bf897ba01 84 /** Determine whether the data is chunked
jlind6 17:951bf897ba01 85 * Recovered from Transfer-Encoding header
jlind6 17:951bf897ba01 86 */
jlind6 17:951bf897ba01 87 virtual void setIsChunked(bool chunked) = 0;
jlind6 17:951bf897ba01 88
jlind6 17:951bf897ba01 89 /** If the data is not chunked, set its size
jlind6 17:951bf897ba01 90 * From Content-Length header
jlind6 17:951bf897ba01 91 */
jlind6 17:951bf897ba01 92 virtual void setDataLen(size_t len) = 0;
jlind6 17:951bf897ba01 93
jlind6 17:951bf897ba01 94 };
jlind6 17:951bf897ba01 95
jlind6 17:951bf897ba01 96 #endif