From 64a7e74f7c4832edaf8e5d1980db75eaa1ad44ed Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Windows 11)" <rob@synchro.net> Date: Tue, 21 Nov 2023 20:41:59 -0800 Subject: [PATCH] Don't try to send 0-byte files Saves some opening, reading, and logging, but otherwise was harmeless. Fix issue #422 --- src/sbbs3/websrvr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sbbs3/websrvr.c b/src/sbbs3/websrvr.c index fd5d6febc2..c41e0bbe87 100644 --- a/src/sbbs3/websrvr.c +++ b/src/sbbs3/websrvr.c @@ -6171,11 +6171,12 @@ static void respond(http_session_t * session) send_headers(session,session->req.status,FALSE); } } - if(session->req.send_content) { + int64_t content_length = flength(session->req.physical_path); + if(session->req.send_content && content_length > 0) { off_t snt=0; time_t start = time(NULL); lprintf(LOG_INFO,"%04d Sending file: %s (%"PRIdOFF" bytes)" - ,session->socket, session->req.physical_path, flength(session->req.physical_path)); + ,session->socket, session->req.physical_path, content_length); snt=sock_sendfile(session,session->req.physical_path,session->req.range_start,session->req.range_end); if(session->req.ld!=NULL) { if(snt<0) -- GitLab