#ifndef __HTTPSERV_H__ #define __HTTPSERV_H__ #include #include #include #include #include #include #include class HttpResponse : public Base { public: typedef enum { HTTP_200_OK = 200, HTTP_301_PERM_MOVED = 301, HTTP_302_FOUND = 302, HTTP_400_BAD_REQUEST = 400, HTTP_401_UNAUTHORIZED = 401, HTTP_403_FORBIDDEN = 403, HTTP_404_NOT_FOUND = 404, HTTP_500_INTERNAL_ERROR = 500, HTTP_503_SERVICE_UNAVAILABLE = 503, } return_code_t; HttpResponse(); virtual ~HttpResponse(); Task * BuildResponse(Handle * out); void PrepareResponse(Handle * b = 0); String mime_type; String location; String server_name; return_code_t return_code; time_t last_modified; Buffer contents; bool cache; Task * builder; private: String code_to_string(); bool already_prepared; }; class HttpRequest : public Base { public: Variables * vars, * headers; String uri; }; class Action; class HttpServ : public Task { public: HttpServ(Action *, int = 1500, const String & = String("GruiK Server v0.2")) throw (GeneralException); virtual ~HttpServ(); virtual String GetName(); void SetRoot(const String &); protected: virtual int Do() throw (GeneralException); private: Socket Listener; Action * p; String name; int localport; String root; }; extern String endhl, endnl; #include #endif