From 102ee5518358387637ab48ddcf1f2b8fe5d5bd80 Mon Sep 17 00:00:00 2001 From: Astazium <113135541+Astazium@users.noreply.github.com> Date: Tue, 22 Sep 2026 16:42:47 +0300 Subject: [PATCH] fix styling violations --- res/scripts/classes.lua | 5 ++--- src/network/Sockets.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/res/scripts/classes.lua b/res/scripts/classes.lua index efa0da894..d9047ea58 100644 --- a/res/scripts/classes.lua +++ b/res/scripts/classes.lua @@ -98,6 +98,7 @@ local _udp_server_callbacks = {} local _udp_client_datagram_callbacks = {} local _udp_client_open_callbacks = {} local _http_response_callbacks = {} +local _http_server_handlers = {} local http_request = network.__request local open_tcp = network.__open_tcp @@ -225,8 +226,6 @@ network.udp_connect = function (address, port, datagramHandler, openCallback) return socket end -local _http_server_handlers = {} - local HttpRequest = {__index={ respond=function(self, status, body, headers) if self.responded then @@ -244,7 +243,7 @@ local HttpRequest = {__index={ }} network.http_open = function(port, handler, timeout_ms) - if handler == nil then + if type(handler) ~= "function" then error "http server cannot be opened without a request handler" end local socket = setmetatable({id=http_open(port, timeout_ms or 60000)}, ServerSocket) diff --git a/src/network/Sockets.cpp b/src/network/Sockets.cpp index 44daa1a7b..ed5e16b73 100644 --- a/src/network/Sockets.cpp +++ b/src/network/Sockets.cpp @@ -1031,10 +1031,14 @@ namespace { size_t pos = lineEnd == std::string::npos ? head.size() : lineEnd + 2; while (pos < head.size()) { size_t next = head.find("\r\n", pos); - if (next == std::string::npos) next = head.size(); + if (next == std::string::npos) { + next = head.size(); + } std::string line = head.substr(pos, next - pos); pos = next + 2; - if (line.empty() || line.find(':') == std::string::npos) continue; + if (line.empty() || line.find(':') == std::string::npos) { + continue; + } auto [name, value] = util::split_at(line, ':'); util::trim(name);