增加获取全部请求头

This commit is contained in:
NH
2025-04-17 18:19:09 +08:00
parent 75171c7f8a
commit 90639f939f
2 changed files with 21 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ namespace ylib
/// <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>

View File

@@ -46,7 +46,26 @@ bool ylib::network::http::request::header(const std::string &name, std::string &
value = strutils::F(lpszValue);
return true;
}
std::vector<ylib::KeyValue<std::string, std::string>> ylib::network::http::request::headers()
{
std::vector<ylib::KeyValue<std::string, std::string>> hs;
DWORD dwHeaderCount = 0;
HPSERVER->GetAllHeaders((CONNID)m_reqpack->connid(), nullptr, dwHeaderCount);
if (dwHeaderCount > 0)
{
THeader* headers = new THeader[dwHeaderCount];
HPSERVER->GetAllHeaders((CONNID)m_reqpack->connid(), headers, dwHeaderCount);
for (DWORD i = 0; i < dwHeaderCount; i++)
{
ylib::KeyValue<std::string,std::string > kv;
kv.name = strutils::F(headers[i].name);
kv.value = strutils::F(headers[i].value);
hs.push_back(kv);
}
delete[] headers;
}
return hs;
}
std::string ylib::network::http::request::method()
{
if (m_method.empty())