source: box/trunk/lib/httpserver/HTTPServer.h @ 2504

Revision 2504, 2.2 KB checked in by chris, 3 years ago (diff)

Move S3Simulator into its own class, like S3Client, for reuse elsewhere.

Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    HTTPServer.h
5//              Purpose: HTTP server class
6//              Created: 26/3/04
7//
8// --------------------------------------------------------------------------
9
10#ifndef HTTPSERVER__H
11#define HTTPSERVER__H
12
13#include "ServerStream.h"
14#include "SocketStream.h"
15
16class HTTPRequest;
17class HTTPResponse;
18
19// --------------------------------------------------------------------------
20//
21// Class
22//              Name:    HTTPServer
23//              Purpose: HTTP server
24//              Created: 26/3/04
25//
26// --------------------------------------------------------------------------
27class HTTPServer : public ServerStream<SocketStream, 80>
28{
29public:
30        HTTPServer();
31        ~HTTPServer();
32private:
33        // no copying
34        HTTPServer(const HTTPServer &);
35        HTTPServer &operator=(const HTTPServer &);
36public:
37
38        int GetTimeout() const {return mTimeout;}
39
40        // --------------------------------------------------------------------------
41        //
42        // Function
43        //              Name:    HTTPServer::Handle(const HTTPRequest &, HTTPResponse &)
44        //              Purpose: Response to a request, filling in the response object for sending
45        //                               at some point in the future.
46        //              Created: 26/3/04
47        //
48        // --------------------------------------------------------------------------
49        virtual void Handle(HTTPRequest &rRequest, HTTPResponse &rResponse) = 0;
50       
51        // For notifications to derived classes
52        virtual void HTTPConnectionOpening();
53        virtual void HTTPConnectionClosing();
54
55protected:
56        void SendInternalErrorResponse(const std::string& rErrorMsg,
57                HTTPResponse& rResponse);
58        int GetTimeout() { return mTimeout; }
59
60private:
61        int mTimeout;   // Timeout for read operations
62        const char *DaemonName() const;
63        const ConfigurationVerify *GetConfigVerify() const;
64        void Run();
65        void Connection(SocketStream &rStream);
66};
67
68// Root level
69#define HTTPSERVER_VERIFY_ROOT_KEYS \
70        ConfigurationVerifyKey("AddressPrefix", \
71                ConfigTest_Exists | ConfigTest_LastEntry)
72
73// AddressPrefix is, for example, http://localhost:1080 -- ie the beginning of the URI
74// This is used for handling redirections.
75
76// Server level
77#define HTTPSERVER_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES) \
78        SERVERSTREAM_VERIFY_SERVER_KEYS(DEFAULT_ADDRESSES)
79
80#endif // HTTPSERVER__H
81
Note: See TracBrowser for help on using the repository browser.