Serenity Operating System
at master 41 lines 1.0 kB view raw
1/* 2 * Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <LibWebSocket/ConnectionInfo.h> 8 9namespace WebSocket { 10 11ConnectionInfo::ConnectionInfo(URL url) 12 : m_url(move(url)) 13{ 14} 15 16bool ConnectionInfo::is_secure() const 17{ 18 // RFC 6455 Section 3 : 19 // The URI is called "secure" if the scheme component matches "wss" case-insensitively. 20 return m_url.scheme().equals_ignoring_ascii_case("wss"sv); 21} 22 23DeprecatedString ConnectionInfo::resource_name() const 24{ 25 // RFC 6455 Section 3 : 26 // The "resource-name" can be constructed by concatenating the following: 27 StringBuilder builder; 28 // "/" if the path component is empty 29 if (m_url.path().is_empty()) 30 builder.append('/'); 31 // The path component 32 builder.append(m_url.path()); 33 // "?" if the query component is non-empty 34 if (!m_url.query().is_empty()) 35 builder.append('?'); 36 // the query component 37 builder.append(m_url.query()); 38 return builder.to_deprecated_string(); 39} 40 41}