00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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) {}
00094 HttpClientSocket& operator=(const HttpClientSocket& ) { return *this; }
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 }
00118 #endif
00119 #endif // _SOCKETS_HttpClientSocket_H