Ollie Milton / HTTPClient

Fork of HTTPClient by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HTTPFile.cpp Source File

HTTPFile.cpp

00001 #include "HTTPFile.h"
00002 
00003 HTTPFile::HTTPFile(char* filename) {
00004     file = fopen(filename, "w");    
00005 }
00006 
00007 void HTTPFile::close() {
00008     if (file) {
00009         fclose(file);    
00010     }        
00011 }
00012 
00013 void HTTPFile::writeReset() {
00014     if (file) {
00015         rewind(file);   
00016     }
00017 }
00018 
00019 int HTTPFile::write(const char* buf, size_t len) {
00020     if (file) {
00021         len = fwrite(buf, 1, len, file);    
00022         if ((!m_chunked && (ftell(file) >= m_len)) || (m_chunked && !len)) {
00023             close();
00024         }
00025     }
00026     return len;    
00027 }
00028 
00029 void HTTPFile::setDataType(const char* type) {
00030 
00031 }
00032 
00033 void HTTPFile::setIsChunked(bool chunked) {
00034     m_chunked = chunked;
00035 }
00036 
00037 void HTTPFile::setDataLen(size_t len) {
00038     m_len = len;
00039 }