big svn cleanup
[anytun.git] / src / Sockets / HttpBaseSocket.h
blob8ce4ad8c07efeb22a601d94824d4732ca4d36d05
1 /**
2 ** \file HttpBaseSocket.h
3 ** \date 2007-10-05
4 ** \author grymse@alhem.net
5 **/
6 /*
7 Copyright (C) 2007 Anders Hedstrom
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #ifndef _HttpBaseSocket_H
24 #define _HttpBaseSocket_H
26 #include "HTTPSocket.h"
27 #include "HttpRequest.h"
28 #include "IHttpServer.h"
30 #ifdef SOCKETS_NAMESPACE
31 namespace SOCKETS_NAMESPACE {
32 #endif
35 class HttpResponse;
37 class HttpBaseSocket : public HTTPSocket, public IHttpServer
39 public:
40 HttpBaseSocket(ISocketHandler& h);
41 ~HttpBaseSocket();
43 void OnFirst();
44 void OnHeader(const std::string& key,const std::string& value);
45 void OnHeaderComplete();
46 void OnData(const char *,size_t);
48 // implements IHttpServer::Respond
49 void Respond(const HttpResponse& res);
51 void OnTransferLimit();
53 protected:
54 HttpBaseSocket(const HttpBaseSocket& s) : HTTPSocket(s) {} // copy constructor
56 HttpRequest m_req;
57 void Reset();
59 private:
60 HttpBaseSocket& operator=(const HttpBaseSocket& ) { return *this; } // assignment operator
61 void Execute();
63 size_t m_body_size_left;
64 const IFile *m_res_file;
65 bool m_b_keepalive;
71 #ifdef SOCKETS_NAMESPACE
72 } // namespace SOCKETS_NAMESPACE {
73 #endif
75 #endif // _HttpBaseSocket_H