Dependencies:   DMSupport DMemWin

Committer:
destinyXfate
Date:
Thu Jun 02 05:04:57 2016 +0000
Revision:
0:08606a13a816
;

Who changed what in which revision?

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