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 #ifndef _SOCKETS_HttpClientSocket_H
00032 #define _SOCKETS_HttpClientSocket_H
00033
00034 #include "sockets-config.h"
00035 #include "HTTPSocket.h"
00036
00037 #ifdef SOCKETS_NAMESPACE
00038 namespace SOCKETS_NAMESPACE {
00039 #endif
00040
00043 class HttpClientSocket : public HTTPSocket
00044 {
00045 public:
00046 HttpClientSocket(ISocketHandler&);
00047 HttpClientSocket(ISocketHandler&,const std::string& url_in);
00048 HttpClientSocket(ISocketHandler&,const std::string& host, port_t port, const std::string& url_in);
00049 ~HttpClientSocket();
00050
00052 void Url(const std::string& url_in,std::string& host,port_t& port);
00053
00054 void OnFirst();
00055 void OnHeader(const std::string&,const std::string&);
00056 void OnHeaderComplete();
00057 void OnData(const char *,size_t);
00058 void OnDelete();
00059
00061 virtual void OnContent();
00062
00064 void SetFilename(const std::string& );
00065 const std::string& Filename() const { return m_filename; }
00066
00068 void SetDataPtr(unsigned char *,size_t);
00069
00071 const std::string& GetContent();
00072
00074 size_t GetContentLength();
00075
00077 const std::string& GetContentType();
00078
00080 size_t GetContentPtr();
00082 size_t GetPos();
00083
00085 bool Complete();
00086
00088 const unsigned char *GetDataPtr() const;
00089
00091 void SetCloseOnComplete(bool = true);
00092
00094 const std::string& GetUrlProtocol();
00096 const std::string& GetUrlHost();
00098 port_t GetUrlPort();
00100 const std::string& GetUrlFilename();
00101
00102 protected:
00103 HttpClientSocket(const HttpClientSocket& s) : HTTPSocket(s) {}
00104 HttpClientSocket& operator=(const HttpClientSocket& ) { return *this; }
00105 private:
00106 std::string m_filename;
00107 unsigned char *m_data_ptr;
00108 size_t m_data_size;
00109 size_t m_content_length;
00110 std::string m_content;
00111 bool m_data_ptr_set;
00112 FILE *m_fil;
00113 size_t m_content_ptr;
00114 bool m_b_complete;
00115 bool m_b_close_when_complete;
00116 std::string m_protocol;
00117 std::string m_host;
00118 port_t m_port;
00119 std::string m_url_filename;
00120 std::string m_content_type;
00121 };
00122
00123
00124
00125
00126 #ifdef SOCKETS_NAMESPACE
00127 }
00128 #endif
00129 #endif // _SOCKETS_HttpClientSocket_H
00130