mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 19:25:51 +00:00
Add HTTPHeaders::build_map
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace beast {
|
||||
|
||||
HTTPHeaders::HTTPHeaders ()
|
||||
@@ -86,4 +88,20 @@ String HTTPHeaders::toString () const
|
||||
return s;
|
||||
}
|
||||
|
||||
std::map <std::string, std::string>
|
||||
HTTPHeaders::build_map() const
|
||||
{
|
||||
std::map <std::string, std::string> c;
|
||||
auto const& k (m_fields.getAllKeys());
|
||||
auto const& v (m_fields.getAllValues());
|
||||
for (std::size_t i = 0; i < m_fields.size(); ++i)
|
||||
{
|
||||
auto key (k[i].toStdString());
|
||||
auto const value (v[i].toStdString());
|
||||
std::transform (key.begin(), key.end(), key.begin(), ::tolower);
|
||||
c[key] = value;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#define BEAST_ASIO_HTTPHEADERS_H_INCLUDED
|
||||
|
||||
#include <beast/module/asio/http/HTTPField.h>
|
||||
|
||||
#include <beast/module/core/text/StringPairArray.h>
|
||||
#include <map>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -70,6 +70,10 @@ public:
|
||||
/** Outputs all the headers into one string. */
|
||||
String toString () const;
|
||||
|
||||
// VFALCO HACK to present the headers in a useful format
|
||||
std::map <std::string, std::string>
|
||||
build_map() const;
|
||||
|
||||
private:
|
||||
StringPairArray m_fields;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user