mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00

This commit converts TLS::TLSv12 to a Core::Stream object, and in the process allows TLS to now wrap other Core::Stream::Socket objects. As a large part of LibHTTP and LibGemini depend on LibTLS's interface, this also converts those to support Core::Stream, which leads to a simplification of LibHTTP (as there's no need to care about the underlying socket type anymore). Note that RequestServer now controls the TLS socket options, which is a better place anyway, as RS is the first receiver of the user-requested options (though this is currently not particularly useful).
39 lines
717 B
C++
39 lines
717 B
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/StringBuilder.h>
|
|
#include <AK/URL.h>
|
|
#include <LibGemini/GeminiRequest.h>
|
|
|
|
namespace Gemini {
|
|
|
|
GeminiRequest::GeminiRequest()
|
|
{
|
|
}
|
|
|
|
GeminiRequest::~GeminiRequest()
|
|
{
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
}
|