| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #pragma once
- #include "http_define.h"
- #if USE_NET_HTTP_WEBSITE
- #include <string>
- #include <vector>
- #include "http_interface.h"
- namespace ylib
- {
- namespace network
- {
- namespace http
- {
- class reqpack;
- class server;
- /// <summary>
- /// HTTP请求
- /// </summary>
- class request :public network::http::interface_
- {
- public:
- request(network::http::reqpack* reqpack);
- ~request();
- /// <summary>
- /// 取请求头
- /// </summary>
- /// <param name="name"></param>
- /// <param name="value"></param>
- /// <returns></returns>
- bool header(const std::string& name, std::string& value);
- std::vector<ylib::KeyValue<std::string, std::string>> headers();
- /// <summary>
- /// 请求动作
- /// </summary>
- /// <returns></returns>
- std::string method();
- /// <summary>
- /// 取请求路径
- /// </summary>
- /// <returns></returns>
- std::string filepath();
- /// <summary>
- /// 取请求主机
- /// </summary>
- /// <returns></returns>
- std::string host();
- network::http::reqpack* reqpack();
- /// <summary>
- /// 远程信息
- /// </summary>
- /// <returns></returns>
- ylib::AddressPort remote();
- /// <summary>
- /// 取请求参数
- /// </summary>
- /// <param name="name"></param>
- /// <param name="value"></param>
- /// <returns></returns>
- bool get_url_param(const std::string& name,std::string& value);
- bool get_body_param(const std::string& name, std::string& value);
- std::shared_ptr<std::map<std::string, std::string>>& url_param();
- std::shared_ptr<std::map<std::string, std::string>>& body_param();
- /// <summary>
- /// 表单数据
- /// </summary>
- /// <returns></returns>
- const std::shared_ptr<std::vector<network::http::multipart>>& multipart();
- /// <summary>
- /// 是否为请求类型
- /// </summary>
- /// <returns></returns>
- bool content_type(std::string type_name);
- /// <summary>
- /// Body
- /// </summary>
- /// <returns></returns>
- ylib::buffer& body();
- private:
- // reqpack
- network::http::reqpack* m_reqpack = nullptr;
- // 请求动作
- std::string m_method;
- private:
- // 请求参数[URL]
- std::shared_ptr<std::map<std::string, std::string>> m_url_param;
- // 请求参数[BODY]
- std::shared_ptr<std::map<std::string, std::string>> m_body_param;
- // FORM数据
- std::shared_ptr<std::vector<network::http::multipart>> m_form;
- };
- }
- }
- }
- #endif
|