From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from integral2.. (unknown [36.81.65.188]) by gnuweeb.org (Postfix) with ESMTPSA id 9779F7E312; Fri, 8 Jul 2022 12:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1657282235; bh=njgsC9yDpu2/AtoE+vAXmG3+SkYxshGY300Wnvy3ego=; h=From:To:Cc:Subject:Date:From; b=qgzMLfnMO4GfGEK8+rmFaHWpIxJnNDz6rPtuD+n8j2zx0tsWlsiEFWqbo42zkfdAm TVDydeLBMKg68lY+FHDQAKSkZgYe0Levh2o+4DU8UyTRWT8LEih768EKDzOR6/sArs 1YYsJJdaXYyNdbSNw0ZVmk8mbSGv5rAIlOejOs3dRD8PG9/6k+ymQVOByOa/i8cKl1 qnWNLnv0JGXL33H5myz6oywy9gmVIXIm3Tt6bnK/Eu8uxhahlLFZNU0gZ1DTbVhEUM 5p6RmqZkn6yu1UJxerZ0MhOHcabKywdsucTn1hTpHjuOTiAM50IvqzsFDSx9yX4cZN hbArO8FDSq+Bg== From: Ammar Faizi To: GNU/Weeb Mailing List Cc: Ammar Faizi , Alviro Iskandar Setiawan , Arthur Lapz , Fernanda Ma'rouf , Sprite , Yonle Subject: [PATCH gwhttpd 00/14] gwhttpd updates Date: Fri, 8 Jul 2022 19:10:11 +0700 Message-Id: <20220708121025.926162-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Hi, gwhttpd updates. There are 14 patches in this series. The most interesting part is the new feature, "Range" HTTP header support. I also added SLC support, so now we have a built-in port forwarding feature. ## Summary: 1) Do an early return when `parse_http_header()` fails. Don't continue executing the next line if we fail to parse the HTTP header, that's the wrong path, we should stop the client early. 2) Don't print any error when mlock fails. This mlock is just optional, don't bother showing error. 3) Replace `send_error_and_close()` with `send_http_error()`. Let the caller close the connection, we need to have more decisions in the caller rather than closing it directly. 4) Add log in the interrupt handler. Print a log message that we are interrupted, this makes the app user friendly because the user can explicitly see from the output that the app is interrupted. 5) Refactor HTTP header parser. The HTTP header parser was prone and didn't handle many edge cases. This is a full refactor of HTTP header parser. While in there, add more HTTP method supports. 6) Avoid endless busy spinning on `send()`. When we fail to send() due to EAGAIN, we retry the send(). However, if we are spinning on this retry for so long, this will eat CPU cycle and slow down the entire application. We should stop retrying at some point. Add a loop counter and return -ENETDOWN if we are failing too many times in the send() retry loop cycle. 7) Add "make clean" command. 8) Skip interrupt error from `epoll_wait()`. When the epoll_wait() got -EINTR, we should still continue the program, because it may just be a small interrupt from strace or whatever situation that doesn't need to stop the program. 9) Add directory listing support. 10) Add command line options support with libc getopt. 11) Add SLC support. 12) Shut the SLC log up. The SLC log will be very noisy for gwhttpd, let's just get rid of them! 13) Fix 403 HTTP error when accessing an empty file. Hendra reports that he is seeing an HTTP 403 error when accssing an empty file. It turned out that we fail on the mmap() syscall. mmap() returns -EINVAL if the given size is zero. This happens when the file size is zero. Make a special case when the file size is zero, bump the mmap() size to 1. This way the mmap() will happily allocate a VMA without error. 14) Add connecting log for SLC. Make SLC state clear when we are connecting to the SLC server. Signed-off-by: Ammar Faizi --- Ammar Faizi (14): gwhttpd: Do an early return when `parse_http_header()` fails gwhttpd: Don't print any error when mlock fails gwhttpd: Replace `send_error_and_close()` with `send_http_error()` gwhttpd: Add log in the interrupt handler gwhttpd: Refactor HTTP header parser gwhttpd: Avoid endless busy spinning on `send()` Makefile: Add "make clean" command gwhttpd: Skip interrupt error from `epoll_wait()` gwhttpd: Add directory listing and download file support gwhttpd: Add command line options gwhttpd: Add SLC support gwhttpd: slc: Shut the SLC log up gwhttpd: Fix 403 HTTP error when accessing an empty file gwhttpd: Add connecting log for SLC Makefile | 7 +- gwhttpd.cpp | 2368 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 2005 insertions(+), 370 deletions(-) base-commit: 944b77d9aaac4a88729da6ec2f76447a9c3562ab -- Ammar Faizi