Fawkes API Fawkes Development Version
file_reply.h
1
2/***************************************************************************
3 * file_reply.h - Web request file reply
4 *
5 * Created: Thu Oct 23 13:47:33 2008
6 * Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#ifndef _LIBS_WEBVIEW_FILE_REPLY_H_
24#define _LIBS_WEBVIEW_FILE_REPLY_H_
25
26#include <webview/reply.h>
27
28#include <cstdio>
29
30namespace fawkes {
31
33{
34public:
35 DynamicFileWebReply(const std::string &filename, const std::string &content_type = "");
36 DynamicFileWebReply(const char *filename);
37 DynamicFileWebReply(FILE *file, bool close_when_done = true);
38 virtual ~DynamicFileWebReply();
39
40 virtual size_t size();
41 virtual size_t next_chunk(size_t pos, char *buffer, size_t buf_max_size);
42
43private:
44 void determine_file_size();
45
46private:
47 FILE * file_;
48 size_t size_;
49 bool close_when_done_;
50};
51
52} // end namespace fawkes
53
54#endif
Dynamic raw file transfer reply.
Definition: file_reply.h:33
DynamicFileWebReply(const std::string &filename, const std::string &content_type="")
Constructor.
Definition: file_reply.cpp:45
virtual size_t next_chunk(size_t pos, char *buffer, size_t buf_max_size)
Get data of next chunk.
Definition: file_reply.cpp:120
virtual size_t size()
Total size of the web reply.
Definition: file_reply.cpp:114
virtual ~DynamicFileWebReply()
Destructor.
Definition: file_reply.cpp:94
Dynamic web reply.
Definition: reply.h:126
Fawkes library namespace.