Logo
~Sockets~
~Examples~
~Contact~


HttpClientSocket.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2007  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 */
00023 #ifndef _SOCKETS_HttpClientSocket_H
00024 #define _SOCKETS_HttpClientSocket_H
00025 
00026 #include "sockets-config.h"
00027 #include "HTTPSocket.h"
00028 
00029 #ifdef SOCKETS_NAMESPACE
00030 namespace SOCKETS_NAMESPACE {
00031 #endif
00032 
00035 class HttpClientSocket : public HTTPSocket
00036 {
00037 public:
00038         HttpClientSocket(ISocketHandler&);
00039         HttpClientSocket(ISocketHandler&,const std::string& url_in);
00040         ~HttpClientSocket();
00041 
00043         void Url(const std::string& url_in,std::string& host,port_t& port);
00044 
00045         void OnFirst();
00046         void OnHeader(const std::string&,const std::string&);
00047         void OnHeaderComplete();
00048         void OnData(const char *,size_t);
00049         void OnDelete();
00050 
00052         virtual void OnContent();
00053 
00055         void SetFilename(const std::string& );
00056 
00058         void SetDataPtr(unsigned char *,size_t);
00059 
00061         const std::string& GetContent();
00062 
00064         size_t GetContentLength();
00065 
00067         const std::string& GetContentType();
00068 
00070         size_t GetContentPtr();
00072         size_t GetPos();
00073 
00075         bool Complete();
00076 
00078         const unsigned char *GetDataPtr() const;
00079 
00081         void SetCloseOnComplete(bool = true);
00082 
00084         const std::string& GetUrlProtocol();
00086         const std::string& GetUrlHost();
00088         port_t GetUrlPort();
00090         const std::string& GetUrlFilename();
00091 
00092 protected:
00093         HttpClientSocket(const HttpClientSocket& s) : HTTPSocket(s) {} // copy constructor
00094         HttpClientSocket& operator=(const HttpClientSocket& ) { return *this; } // assignment operator
00095 private:
00096         std::string m_filename; 
00097         unsigned char *m_data_ptr; 
00098         size_t m_data_size; 
00099         size_t m_content_length; 
00100         std::string m_content; 
00101         bool m_data_ptr_set; 
00102         FILE *m_fil; 
00103         size_t m_content_ptr; 
00104         bool m_b_complete; 
00105         bool m_b_close_when_complete; 
00106         std::string m_protocol; 
00107         std::string m_host; 
00108         port_t m_port; 
00109         std::string m_url_filename; 
00110         std::string m_content_type; 
00111 };
00112 
00113 
00114 
00115 
00116 #ifdef SOCKETS_NAMESPACE
00117 } // namespace SOCKETS_NAMESPACE {
00118 #endif
00119 #endif // _SOCKETS_HttpClientSocket_H
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4