acl/lib_fiber/samples-gui/HttpGet/HttpClient.h

47 lines
870 B
C
Raw Normal View History

2021-09-13 00:19:49 +08:00
#pragma once
class CHttpGetDlg;
2021-09-13 16:55:48 +08:00
enum {
HTTP_MSG_ERR,
HTTP_MSG_REQ,
HTTP_MSG_RES,
HTTP_MSG_TOTAL_LENGTH,
HTTP_MSG_LENGTH,
};
class CHttpMsg {
public:
CHttpMsg(const char* s, int type) : m_buf(s), m_length(0), m_type(type) {}
CHttpMsg(long long len, int type) : m_length(len), m_type(type) {}
~CHttpMsg(void) {}
CString m_buf;
long long m_length;
int m_type;
};
2021-09-13 00:19:49 +08:00
class CHttpClient
{
public:
CHttpClient(CHttpGetDlg& hWin, const CString& url);
2021-09-13 16:55:48 +08:00
CHttpClient(acl::fiber_tbox<CHttpMsg>& mBox, const CString& url);
2021-09-13 00:19:49 +08:00
~CHttpClient();
void run();
private:
2021-09-13 16:55:48 +08:00
CHttpGetDlg* m_hWin;
acl::fiber_tbox<CHttpMsg>* m_box;
2021-09-13 00:19:49 +08:00
CString m_url;
2021-09-13 16:55:48 +08:00
private:
void SetError(const char* fmt, ...);
void SetRequestHead(const char* data);
void SetResponseHead(const char* data);
void SetBodyTotalLength(long long length);
void SetBodyLength(long long length);
void SetEnd();
2021-09-13 00:19:49 +08:00
};