00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _SOCKETS_HttpClientSocket_H
00034 #define _SOCKETS_HttpClientSocket_H
00035
00036 #include "sockets-config.h"
00037 #include "HTTPSocket.h"
00038
00039 #ifdef SOCKETS_NAMESPACE
00040 namespace SOCKETS_NAMESPACE {
00041 #endif
00042
00043 class IFile;
00044
00047 class HttpClientSocket : public HTTPSocket
00048 {
00049 public:
00050 HttpClientSocket(ISocketHandler&);
00051 HttpClientSocket(ISocketHandler&,const std::string& url_in);
00052 HttpClientSocket(ISocketHandler&,const std::string& host, port_t port, const std::string& url_in);
00053 ~HttpClientSocket();
00054
00056 void Url(const std::string& url_in,std::string& host,port_t& port);
00057
00058 void OnFirst();
00059 void OnHeader(const std::string&,const std::string&);
00060 void OnHeaderComplete();
00061 void OnData(const char *,size_t);
00062 void OnDelete();
00063
00065 virtual void OnContent();
00066
00068 void SetFilename(const std::string& );
00069 const std::string& Filename() const { return m_filename; }
00070
00072 void SetDataPtr(unsigned char *,size_t);
00073
00075 const std::string& GetContent();
00076
00078 size_t GetContentLength();
00079
00081 const std::string& GetContentType();
00082
00084 size_t GetContentPtr();
00086 size_t GetPos();
00087
00089 bool Complete();
00090
00092 const unsigned char *GetDataPtr() const;
00093
00095 void SetCloseOnComplete(bool = true);
00096
00098 const std::string& GetUrlProtocol();
00100 const std::string& GetUrlHost();
00102 port_t GetUrlPort();
00104 const std::string& GetUrlFilename();
00105
00106 protected:
00107 HttpClientSocket(const HttpClientSocket& s) : HTTPSocket(s) {}
00108 HttpClientSocket& operator=(const HttpClientSocket& ) { return *this; }
00109 private:
00110 void EndConnection();
00111 std::string m_filename;
00112 unsigned char *m_data_ptr;
00113 size_t m_data_size;
00114 size_t m_content_length;
00115 bool m_content_length_is_set;
00116 std::string m_content;
00117 bool m_data_ptr_set;
00118 IFile *m_fil;
00119 size_t m_content_ptr;
00120 bool m_b_complete;
00121 bool m_b_close_when_complete;
00122 std::string m_protocol;
00123 std::string m_host;
00124 port_t m_port;
00125 std::string m_url_filename;
00126 std::string m_content_type;
00127 };
00128
00129
00130
00131
00132 #ifdef SOCKETS_NAMESPACE
00133 }
00134 #endif
00135 #endif // _SOCKETS_HttpClientSocket_H
00136