mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
LibHTTP: Make HeaderMap movable and copyable
This commit is contained in:
parent
d704b61066
commit
7f72c28e78
Notes:
github-actions[bot]
2024-11-20 20:44:35 +00:00
Author: https://github.com/alimpfard Commit: https://github.com/LadybirdBrowser/ladybird/commit/7f72c28e78b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2111 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 14 additions and 4 deletions
|
@ -15,6 +15,19 @@ public:
|
||||||
HeaderMap() = default;
|
HeaderMap() = default;
|
||||||
~HeaderMap() = default;
|
~HeaderMap() = default;
|
||||||
|
|
||||||
|
HeaderMap(Vector<Header> headers)
|
||||||
|
: m_headers(move(headers))
|
||||||
|
{
|
||||||
|
for (auto& header : m_headers)
|
||||||
|
m_map.set(header.name, header.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
HeaderMap(HeaderMap const&) = default;
|
||||||
|
HeaderMap(HeaderMap&&) = default;
|
||||||
|
|
||||||
|
HeaderMap& operator=(HeaderMap const&) = default;
|
||||||
|
HeaderMap& operator=(HeaderMap&&) = default;
|
||||||
|
|
||||||
void set(ByteString name, ByteString value)
|
void set(ByteString name, ByteString value)
|
||||||
{
|
{
|
||||||
m_map.set(name, value);
|
m_map.set(name, value);
|
||||||
|
@ -56,10 +69,7 @@ template<>
|
||||||
inline ErrorOr<HTTP::HeaderMap> decode(Decoder& decoder)
|
inline ErrorOr<HTTP::HeaderMap> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
auto headers = TRY(decoder.decode<Vector<HTTP::Header>>());
|
auto headers = TRY(decoder.decode<Vector<HTTP::Header>>());
|
||||||
HTTP::HeaderMap header_map;
|
return HTTP::HeaderMap { move(headers) };
|
||||||
for (auto& header : headers)
|
|
||||||
header_map.set(move(header.name), move(header.value));
|
|
||||||
return header_map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue