acl/lib_acl_cpp/samples/HttpClient/HttpDownload.h

48 lines
1.3 KiB
C
Raw Normal View History

2014-11-19 00:25:21 +08:00
#pragma once
#include "lib_acl.h"
#include "lib_protocol.h" // http Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#include "acl_cpp/stream/ofstream.hpp"
#include "acl_cpp/http/http_service.hpp"
class acl::string;
class acl::aio_handle;
class CHttpDownload : public acl::http_service_request
{
public:
CHttpDownload(const char* domain, unsigned short port,
acl::aio_handle* handle);
#ifdef WIN32
void SetHWnd(HWND hWnd);
#endif
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿڣ<D3BF><DAA3><EFBFBD><EFBFBD>ٹ<EFBFBD><D9B9>̣<EFBFBD><CCA3><EFBFBD> http_service <20><EFBFBD><E0B4A6><EFBFBD><EFBFBD><EFBFBD>Ϻ<EFBFBD><CFBA>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>øûص<C3BB>
virtual void destroy();
protected:
~CHttpDownload(void);
//////////////////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
// <20><><EFBFBD><EFBFBD>HTTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ļص<C4BB><D8B5>ӿڣ<D3BF>ע<EFBFBD><D7A2><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5>ÿռ<C3BF><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ
// һ<><D2BB><EFBFBD>߳̿ռ<D5BC><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>Դʱ<D4B4><CAB1>Ҫע<D2AA><EFBFBD><E2BBA5>
virtual const acl::string* get_body();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <20><>Ӧͷʱ<CDB7>Ļص<C4BB><D8B5>ӿ<EFBFBD>
virtual void on_hdr(const char* addr, const HTTP_HDR_RES* hdr);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <20><>Ӧ<EFBFBD><D3A6>ʱ<EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
virtual void on_body(const char* data, size_t dlen);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧʧ<D3A6><CAA7>ʱ<EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
virtual void on_error(acl::http_status_t errnum);
private:
acl::ofstream out_;
acl::aio_handle* handle_;
#ifdef WIN32
HWND hWnd_;
#endif
http_off_t read_length_;
http_off_t content_length_;
time_t begin_;
};