aboutsummaryrefslogtreecommitdiff
path: root/lib/network/http_file.h
blob: a9c86c5c907230ba9fb158c5fcb4f54ec81c0b88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef __http_file_h
#define __http_file_h

#include "httpd.h"

class eHTTPFile: public eHTTPDataSource
{
	DECLARE_REF(eHTTPFile);
private:	
	int fd, size;
	const char *mime;
	int method;
public:
	enum { methodGET, methodPUT };
	eHTTPFile(eHTTPConnection *c, int fd, int method, const char *mime);
	~eHTTPFile();
	int doWrite(int);
	void haveData(void *data, int len);
};

class eHTTPFilePathResolver: public iHTTPPathResolver
{
	DECLARE_REF(eHTTPFilePathResolver);
public:
	struct eHTTPFilePath
	{
		std::string path;
		std::string root;
		int authorized; // must be authorized (1 means read, 2 write)
		eHTTPFilePath(std::string path, std::string root, int authorized): path(path), root(root), authorized(authorized)
		{
		}
	};
	ePtrList<eHTTPFilePath> translate;
public:
	eHTTPFilePathResolver();
	RESULT getDataSource(eHTTPDataSourcePtr &ptr, std::string request, std::string path, eHTTPConnection *conn);
	void addTranslation(std::string path, std::string root, int auth);
};

#endif