178cec2cfedbda85751a27fc983f5ce53d69180c
[mediaserv.git] / Server / HTTPConnection.hh
1 // $Id$
2 //
3 // Copyright (C) 2006 
4
5 #ifndef HH_HTTPConnection_
6 #define HH_HTTPConnection_ 1
7
8 // Custom includes
9 #include <boost/utility.hpp>
10 #include <boost/intrusive_ptr.hpp>
11 #include <boost/scoped_ptr.hpp>
12 #include "Socket/ClientSocketHandle.hh"
13 #include "Utils/intrusive_refcount.hh"
14 #include "Scheduler/ReadHelper.hh"
15 #include "Scheduler/WriteHelper.hh"
16 #include "HTTPLogger.hh"
17 #include "HTTPRequest.hh"
18
19 //#include "HTTPConnection.mpp"
20 ///////////////////////////////hh.p////////////////////////////////////////
21
22 namespace g0dil {
23 namespace mediaserv {
24
25     class SimpleHTTPServer;
26     class StreamConnection;
27
28     class HTTPConnection
29         : public senf::intrusive_refcount
30     {
31     public:
32         ///////////////////////////////////////////////////////////////////////////
33         // Types
34
35         typedef boost::intrusive_ptr<HTTPConnection> ptr;
36         typedef senf::ClientSocketHandle<
37             senf::MakeSocketPolicy<senf::ConnectedCommunicationPolicy,
38                                           senf::StreamFramingPolicy,
39                                           senf::ReadablePolicy,
40                                           senf::WriteablePolicy>::policy> ClientHandle;
41
42         static const unsigned MaxRequestSize = 16384;
43         static const unsigned StreamBufferMSecs = 4000;
44
45         ///////////////////////////////////////////////////////////////////////////
46         ///\name Structors and default members
47         ///@{
48
49         HTTPConnection(ClientHandle client, SimpleHTTPServer & server, HTTPLogger & logger);
50         ~HTTPConnection();
51
52         ///@}
53         ///////////////////////////////////////////////////////////////////////////
54
55         void done();
56
57     protected:
58
59     private:
60         void handleRequest(senf::ReadHelper<ClientHandle>::ptr);
61         void startStream(senf::WriteHelper<ClientHandle>::ptr);
62         
63         ClientHandle client_;
64         SimpleHTTPServer & server_;
65         HTTPLogger & logger_;
66         HTTPRequest request_;
67         boost::scoped_ptr<StreamConnection> connection_;
68         int fileFd_;
69         unsigned bandwidth_;
70     };
71
72 }}
73
74 ///////////////////////////////hh.e////////////////////////////////////////
75 //#include "HTTPConnection.cci"
76 //#include "HTTPConnection.ct"
77 //#include "HTTPConnection.cti"
78 //#include "HTTPConnection.mpp"
79 #endif
80
81 \f
82 // Local Variables:
83 // mode: c++
84 // End: