mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 18:24:45 -05:00
97fcbdd199
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
31 lines
649 B
C++
31 lines
649 B
C++
/*
|
|
* Copyright (c) 2020-2022, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/StringBuilder.h>
|
|
#include <AK/URL.h>
|
|
#include <LibGemini/GeminiRequest.h>
|
|
|
|
namespace Gemini {
|
|
|
|
ByteBuffer GeminiRequest::to_raw_request() const
|
|
{
|
|
StringBuilder builder;
|
|
builder.append(m_url.to_string());
|
|
builder.append("\r\n");
|
|
return builder.to_byte_buffer();
|
|
}
|
|
|
|
Optional<GeminiRequest> GeminiRequest::from_raw_request(const ByteBuffer& raw_request)
|
|
{
|
|
URL url = StringView(raw_request);
|
|
if (!url.is_valid())
|
|
return {};
|
|
GeminiRequest request;
|
|
request.m_url = url;
|
|
return request;
|
|
}
|
|
|
|
}
|