mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:27:35 +00:00
AK: Make URL::m_port an Optional<u16>, Expose raw port getter
Our current way of signalling a missing port with m_port == 0 was lacking, as 0 is a valid port number in URLs.
This commit is contained in:
parent
1c9c43785d
commit
d6cfa34667
15 changed files with 42 additions and 41 deletions
|
@ -34,7 +34,7 @@ void TCPWebSocketConnectionImpl::connect(ConnectionInfo const& connection)
|
|||
m_socket->on_connected = [this] {
|
||||
on_connected();
|
||||
};
|
||||
bool success = m_socket->connect(connection.url().host(), connection.url().port());
|
||||
bool success = m_socket->connect(connection.url().host(), connection.url().port_or_default());
|
||||
if (!success) {
|
||||
deferred_invoke([this] {
|
||||
on_connection_error();
|
||||
|
|
|
@ -42,7 +42,7 @@ void TLSv12WebSocketConnectionImpl::connect(ConnectionInfo const& connection)
|
|||
m_socket->on_tls_certificate_request = [](auto&) {
|
||||
// FIXME : Once we handle TLS certificate requests, handle it here as well.
|
||||
};
|
||||
bool success = m_socket->connect(connection.url().host(), connection.url().port());
|
||||
bool success = m_socket->connect(connection.url().host(), connection.url().port_or_default());
|
||||
if (!success) {
|
||||
deferred_invoke([this] {
|
||||
on_connection_error();
|
||||
|
|
|
@ -151,10 +151,10 @@ void WebSocket::send_client_handshake()
|
|||
// 4. Host
|
||||
auto url = m_connection.url();
|
||||
builder.appendff("Host: {}", url.host());
|
||||
if (!m_connection.is_secure() && url.port() != 80)
|
||||
builder.appendff(":{}", url.port());
|
||||
else if (m_connection.is_secure() && url.port() != 443)
|
||||
builder.appendff(":{}", url.port());
|
||||
if (!m_connection.is_secure() && url.port_or_default() != 80)
|
||||
builder.appendff(":{}", url.port_or_default());
|
||||
else if (m_connection.is_secure() && url.port_or_default() != 443)
|
||||
builder.appendff(":{}", url.port_or_default());
|
||||
builder.append("\r\n");
|
||||
|
||||
// 5. and 6. Connection Upgrade
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue