net/include/pion/net/HTTPReader.hpp

00001 // ------------------------------------------------------------------
00002 // pion-net: a C++ framework for building lightweight HTTP interfaces
00003 // ------------------------------------------------------------------
00004 // Copyright (C) 2007-2008 Atomic Labs, Inc.  (http://www.atomiclabs.com)
00005 //
00006 // Distributed under the Boost Software License, Version 1.0.
00007 // See http://www.boost.org/LICENSE_1_0.txt
00008 //
00009 
00010 #ifndef __PION_HTTPREADER_HEADER__
00011 #define __PION_HTTPREADER_HEADER__
00012 
00013 #include <boost/asio.hpp>
00014 #include <pion/PionConfig.hpp>
00015 #include <pion/net/HTTPParser.hpp>
00016 #include <pion/net/HTTPMessage.hpp>
00017 #include <pion/net/TCPConnection.hpp>
00018 
00019 
00020 namespace pion {    // begin namespace pion
00021 namespace net {     // begin namespace net (Pion Network Library)
00022 
00023 
00027 class PION_NET_API HTTPReader :
00028     public HTTPParser
00029 {
00030 public:
00031 
00032     // default destructor
00033     virtual ~HTTPReader() {}
00034     
00036     void receive(void);
00037     
00039     inline TCPConnectionPtr& getTCPConnection(void) { return m_tcp_conn; }
00040 
00041     
00042 protected:
00043 
00051     HTTPReader(const bool is_request, TCPConnectionPtr& tcp_conn)
00052         : HTTPParser(is_request), m_tcp_conn(tcp_conn) {}   
00053     
00060     void consumeBytes(const boost::system::error_code& read_error,
00061                       std::size_t bytes_read);
00062 
00064     void consumeBytes(void);
00065     
00067     virtual void readBytes(void) = 0;
00068 
00070     virtual void finishedReading(void) = 0;
00071 
00073     virtual HTTPMessage& getMessage(void) = 0;
00074 
00075 
00076 private:
00077 
00083     void handleReadError(const boost::system::error_code& read_error);
00084 
00085 
00087     TCPConnectionPtr                        m_tcp_conn;
00088 };
00089 
00090 
00091 }   // end namespace net
00092 }   // end namespace pion
00093 
00094 #endif

Generated on Fri Dec 4 08:54:29 2009 for pion-net by  doxygen 1.4.7