mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:02:44 +00:00 
			
		
		
		
	 e76394d96c
			
		
	
	
		e76394d96c
		
	
	
	
	
		
			
			Also drop the try_ prefix from the fallible function, as it is no longer needed to distinguish the two.
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			689 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			689 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 {
 | |
| 
 | |
| ErrorOr<ByteBuffer> GeminiRequest::to_raw_request() const
 | |
| {
 | |
|     StringBuilder builder;
 | |
|     TRY(builder.try_append(m_url.to_deprecated_string()));
 | |
|     TRY(builder.try_append("\r\n"sv));
 | |
|     return builder.to_byte_buffer();
 | |
| }
 | |
| 
 | |
| Optional<GeminiRequest> GeminiRequest::from_raw_request(ByteBuffer const& raw_request)
 | |
| {
 | |
|     URL url = StringView(raw_request);
 | |
|     if (!url.is_valid())
 | |
|         return {};
 | |
|     GeminiRequest request;
 | |
|     request.m_url = url;
 | |
|     return request;
 | |
| }
 | |
| 
 | |
| }
 |