Renesas / SecureDweet
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IHttpDataOut.h Source File

IHttpDataOut.h

00001 /*
00002  * IHttpDataOut.h
00003  *
00004  *  Created on: Aug 15, 2016
00005  *      Author: Faheem Inayat
00006  * Created for: Renesas Electronics America HQ, Santa Clara, CA, USA
00007  * 
00008  * Copyright (c) 2016 Renesas Electronics America (REA) and Faheem Inayat
00009  */
00010 /* Copyright (C) 2012 mbed.org, MIT License
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00013  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00014  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00015  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00016  * furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included in all copies or
00019  * substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00022  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00023  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00024  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00025  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00026  */
00027 
00028 #ifndef IHTTPDATAOUT_H_
00029     #define IHTTPDATAOUT_H_
00030 
00031 #include "stddef.h"
00032 
00033 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
00034 class IHttpDataOut
00035 {
00036     public:
00037         IHttpDataOut ();
00038         virtual ~IHttpDataOut ();
00039 
00040         /** Reset stream to its beginning
00041          * Called by the HTTPClient on each new request
00042          */
00043         virtual void readReset() = 0;
00044 
00045         /** Read a piece of data to be transmitted
00046          * @param buf Pointer to the buffer on which to copy the data
00047          * @param len Length of the buffer
00048          * @param pReadLen Pointer to the variable on which the actual copied data length will be stored
00049          */
00050         virtual int read(char* buf, size_t len, size_t* pReadLen) = 0;
00051 
00052         /** Get MIME type
00053          * @param type Internet media type from Content-Type header
00054          */
00055         virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header
00056 
00057         /** Determine whether the HTTP client should chunk the data
00058          *  Used for Transfer-Encoding header
00059          */
00060         virtual bool getIsChunked() = 0;
00061 
00062         /** If the data is not chunked, get its size
00063          *  Used for Content-Length header
00064          */
00065         virtual size_t getDataLen() = 0;
00066 };
00067 
00068 #endif /* IHTTPDATAOUT_H_ */
00069