#pragma once #include "http_define.h" #if USE_NET_HTTP_WEBSITE #include "http_server.h" #include "http_interface.h" #include "util/strutils.h" #include "util/time.h" namespace ylib { namespace network { namespace http { class server; class response; class request; class website; /// /// 请求包 /// class reqpack:public network::http::interface_ { public: /// /// 构造函数 /// /// /// /// /// /// /// /// /// reqpack(const std::string& url, const std::string& host, const ylib::buffer& data, uint64 connid, network::http::server* server,network::http::website* website, network::http::message_type msg_type, std::shared_ptr ws_msg = nullptr); ~reqpack(); /// /// 请求对象 /// /// const std::shared_ptr& request(); /// /// 回复对象 /// /// const std::shared_ptr& response(); /// /// httpserver /// /// network::http::server* server() { return m_server; } /// /// 连接ID /// /// uint64 connid() { return m_connid; } /// /// 请求完整URL /// /// std::string url() { return m_url; } /// /// 请求路径 /// /// std::string filepath() { return m_filepath; } /// /// 请求主机 /// /// std::string host() { return m_host; } /// /// 请求数据 /// /// ylib::buffer& body() { return m_data; } /// /// 附加数据 /// /// ylib::json& extra() { return m_extra; } /// /// 消息类型 /// /// network::http::message_type msg_type() { return m_msg_type; } /// /// WebSocket消息 /// /// const std::shared_ptr& ws_msg() { return m_ws_msg; } /// /// 设置为关闭连接包 /// void set_close() { m_is_close = true; } bool is_close() { return m_is_close; } private: // 请求 std::shared_ptr m_request; // 回复 std::shared_ptr m_response; // WebSocket消息 std::shared_ptr m_ws_msg; // httpserver network::http::server* m_server = nullptr; // 请求地址 std::string m_url; // 请求路径 std::string m_filepath; // 请求主机 std::string m_host; // 请求数据 ylib::buffer m_data; // 请求ID uint64 m_connid = 0; // 附加数据 ylib::json m_extra; // 消息类型 network::http::message_type m_msg_type = HTTP_SERVER_MESSAGE_TYPE_NORMAL; // 是否为关闭连接包 bool m_is_close = false; }; } } } #endif