mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
e636851481
Instead of using a HashMap<ByteString, ByteString, CaseInsensitive...> everywhere, we now encapsulate this in a class. Even better, the new class also allows keeping track of multiple headers with the same name! This will make it possible for HTTP responses to actually retain all their headers on the perilous journey from RequestServer to LibWeb.
41 lines
721 B
C++
41 lines
721 B
C++
/*
|
|
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/ByteString.h>
|
|
#include <LibIPC/Decoder.h>
|
|
#include <LibIPC/Encoder.h>
|
|
|
|
namespace HTTP {
|
|
|
|
struct Header {
|
|
ByteString name;
|
|
ByteString value;
|
|
};
|
|
|
|
}
|
|
|
|
namespace IPC {
|
|
|
|
template<>
|
|
inline ErrorOr<void> encode(Encoder& encoder, HTTP::Header const& header)
|
|
{
|
|
TRY(encoder.encode(header.name));
|
|
TRY(encoder.encode(header.value));
|
|
return {};
|
|
}
|
|
|
|
template<>
|
|
inline ErrorOr<HTTP::Header> decode(Decoder& decoder)
|
|
{
|
|
auto name = TRY(decoder.decode<ByteString>());
|
|
auto value = TRY(decoder.decode<ByteString>());
|
|
return HTTP::Header { move(name), move(value) };
|
|
}
|
|
|
|
}
|