ladybird/Userland/Libraries/LibGemini/GeminiRequest.cpp
Lenny Maiorani 97fcbdd199 Libraries: Use default constructors/destructors in LibGemini
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."
2022-03-13 22:34:38 +01:00

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;
}
}