Commit graph

342 commits

Author SHA1 Message Date
Denys Vlasenko
b668e52c90 *: placate warnings where strchr/strstr returns constant pointer
Newer glibc is now smarter and can propagate const-ness from those!

function                                             old     new   delta
readtoken1                                          3111    3108      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-02-15 15:15:30 +01:00
Denys Vlasenko
df1ef312a0 httpd: handle bare "Location: URL" redirects from CGIs
Many sites on the Web give those as valid CGI examples -
no "Status:", just "Location:".

function                                             old     new   delta
cgi_io_loop_and_exit                                 620     684     +64
log_cgi_status                                         -      49     +49
.rodata                                           106846  106861     +15
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 128/0)             Total: 128 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-28 17:45:37 +01:00
Denys Vlasenko
052b253696 httpd: add a TODO, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-25 08:17:23 +01:00
Denys Vlasenko
ea7d310ad6 httpd: allow static files in /cgi-bin/, do not search for interpreter twice
function                                             old     new   delta
handle_incoming_and_exit                            2270    2334     +64
send_cgi_and_exit                                    790     754     -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 64/-36)             Total: 28 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-24 17:11:39 +01:00
Denys Vlasenko
a2f8c89aec httpd: code shrink
function                                             old     new   delta
send_file_and_exit                                   931     933      +2
get_line                                             126     120      -6
httpd_main                                           968     959      -9
send_headers                                         708     694     -14
handle_incoming_and_exit                            2285    2270     -15
cgi_io_loop_and_exit                                 635     620     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/5 up/down: 2/-59)             Total: -57 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-24 13:29:50 +01:00
Denys Vlasenko
43982ed499 httpd: code shrink via "split-globals" trick
function                                             old     new   delta
httpd_main                                           957     968     +11
log_and_exit                                          25      26      +1
send_headers                                         712     708      -4
handle_incoming_and_exit                            2292    2285      -7
sigalrm_handler                                      102      93      -9
parse_conf                                          1332    1323      -9
send_cgi_and_exit                                    803     790     -13
cgi_io_loop_and_exit                                 656     635     -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/6 up/down: 12/-63)            Total: -51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-24 05:22:33 +01:00
Denys Vlasenko
1a64fe3594 httpd: implement POSTDATA read timeout, and -K KILLSECS CGI lifetime control
function                                             old     new   delta
cgi_io_loop_and_exit                                 496     656    +160
sigalrm_handler                                        1     102    +101
.rodata                                           106814  106853     +39
send_cgi_and_exit                                    770     803     +33
packed_usage                                       35894   35924     +30
httpd_main                                           950     957      +7
handle_incoming_and_exit                            2297    2292      -5
send_REQUEST_TIMEOUT_and_exit                         10       -     -10
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 6/1 up/down: 370/-15)           Total: 355 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-24 02:01:42 +01:00
Denys Vlasenko
927ff335c5 httpd: fix incorrect == comparison in last commit, must be !=
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-23 11:32:32 +01:00
Denys Vlasenko
5d33dbb67c httpd: smarter handling of CGI's "Status: " header
Do one less write()

function                                             old     new   delta
handle_incoming_and_exit                            2290    2297      +7
cgi_io_loop_and_exit                                 498     500      +2
.rodata                                           106821  106814      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 9/-7)                Total: 2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-23 11:04:28 +01:00
Denys Vlasenko
a5f120b620 httpd: simplify CGI headers handling, check "HTTP/1.1" prefix, not just "HTTP"
function                                             old     new   delta
cgi_io_loop_and_exit                                 477     498     +21
.rodata                                           106830  106821      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 21/-9)              Total: 12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-23 10:14:04 +01:00
Denys Vlasenko
01ea35e81d httpd: simplify CGI code a bit, add a bunch of TODOs and FIXMEs
function                                             old     new   delta
log_and_exit                                          33      25      -8
handle_incoming_and_exit                            2298    2290      -8
send_cgi_and_exit                                    784     770     -14
cgi_io_loop_and_exit                                 538     477     -61
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-91)             Total: -91 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-23 02:18:30 +01:00
Denys Vlasenko
2d78809b74 httpd: do not force clean connection termination on write errors and timeouts
function                                             old     new   delta
send_file_and_exit                                   891     931     +40
send_EOF_and_exit                                      -      14     +14
cgi_io_loop_and_exit                                 535     538      +3
log_and_exit                                          44      33     -11
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 57/-11)             Total: 46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 22:35:58 +01:00
Denys Vlasenko
04d8729adb httpd: make timeout messages less confusing
function                                             old     new   delta
send_file_and_exit                                   891     930     +39

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 21:21:16 +01:00
Denys Vlasenko
d8059bd827 httpd: time out data writes after 60 seconds of no progress
function                                             old     new   delta
prepare_write_timeout                                  -      29     +29
static.tv                                              -      16     +16
httpd_main                                           939     950     +11
send_file_and_exit                                   887     891      +4
handle_incoming_and_exit                            2306    2298      -8
cgi_io_loop_and_exit                                 552     535     -17
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/2 up/down: 60/-25)             Total: 35 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 17:22:06 +01:00
Denys Vlasenko
c1ed0c4049 httpd: optimize header reading timeout code
Set up the signal handler once, outside of main loop.
Do not reset the timer if headers are big - they still are expected
to arrive quickly.

function                                             old     new   delta
httpd_main                                           913     939     +26
handle_incoming_and_exit                            2312    2306      -6
get_line                                             134     126      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 26/-14)             Total: 12 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 15:49:58 +01:00
Denys Vlasenko
52a88341d6 httpd: when reading headers, abort if they are too long
function                                             old     new   delta
get_line                                             130     134      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 15:33:42 +01:00
Denys Vlasenko
f0a63eefae httpd: reject request line and headers with control chars
This removes the need to check various corner cases later.

function                                             old     new   delta
get_line                                             108     130     +22

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 14:33:22 +01:00
Denys Vlasenko
851992f070 httpd: allow http2 requests if proxying, tighten METHOD checks
function                                             old     new   delta
handle_incoming_and_exit                            2264    2312     +48
httpd_main                                           915     913      -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 48/-2)              Total: 46 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 13:58:28 +01:00
Denys Vlasenko
649da41ca4 httpd: fix compilation script of httpd_ratelimit_cgi.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 10:42:20 +01:00
Denys Vlasenko
3f36fe9c2f httpd: add -M MAXCONN - do not accept unlimited number of connections
We were lacking even basic rate-limiting.

function                                             old     new   delta
httpd_main                                           648     915    +267
handle_incoming_and_exit                            2235    2264     +29
packed_usage                                       35868   35894     +26
cgi_io_loop_and_exit                                 537     552     +15
send_headers                                         704     712      +8
get_line                                             106     108      +2
.rodata                                           106829  106830      +1
send_file_and_exit                                   890     887      -3
mini_httpd                                           161       -    -161
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 7/1 up/down: 348/-164)          Total: 184 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-22 01:58:46 +01:00
Denys Vlasenko
5ac9d0a865 httpd: stop disabling/enabling SIGHUP in every child
function                                             old     new   delta
sighup_handler                                        30      47     +17
httpd_main                                           710     695     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 17/-15)              Total: 2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-21 19:16:29 +01:00
Denys Vlasenko
71c703c26b httpd: remove one close() from main loop
function                                             old     new   delta
httpd_main                                           701     710      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-21 19:01:42 +01:00
Denys Vlasenko
38721685af httpd: expand logging: now can see what CGIs are started
function                                             old     new   delta
send_cgi_and_exit                                    711     784     +73
vmstat_main                                          657     708     +51
.rodata                                           106746  106778     +32
send_file_and_exit                                   877     887     +10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 166/0)             Total: 166 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2026-01-21 17:49:40 +01:00
Denys Vlasenko
80e676664e libbb: add yescrypt password hashing support
It seems to work, but not at all optimized for size.
The extra copy of sha256 code need to be removed.

The yescrypt code in libbb/yescrypt/* is adapted from libxcrypt-4.4.38
with minimal edits, hopefully making it easier to track
backports by resetting the tree to this commit,
then comparing changes in upstream libxcrypt to the tree.

function                                             old     new   delta
blockmix_xor_save                                      -    7050   +7050
static.blockmix_xor                                    -    6475   +6475
blockmix                                               -    3390   +3390
SHA256_Transform                                       -    3083   +3083
yescrypt_kdf_body                                      -    1724   +1724
PBKDF2_SHA256                                          -    1003   +1003
smix1                                                  -     960    +960
yescrypt_r                                             -     890    +890
salsa20                                                -     804    +804
smix                                                   -     790    +790
smix2                                                  -     659    +659
blockmix_salsa8_xor                                    -     601    +601
yescrypt_kdf                                           -     479    +479
blockmix_salsa8                                        -     415    +415
Krnd                                                   -     256    +256
_HMAC_SHA256_Init                                      -     213    +213
_SHA256_Update                                         -     198    +198
_SHA256_Final                                          -     195    +195
decode64_uint32                                        -     166    +166
encode64                                               -     153    +153
decode64                                               -     136    +136
libcperciva_HMAC_SHA256_Buf                            -     132    +132
SHA256_Pad_Almost                                      -     131    +131
salsa20_simd_unshuffle                                 -     101    +101
salsa20_simd_shuffle                                   -     101    +101
yes_crypt                                              -      90     +90
libcperciva_SHA256_Buf                                 -      86     +86
crypt_make_rand64encoded                               -      85     +85
static.atoi64_partial                                  -      77     +77
alloc_region                                           -      72     +72
ascii64                                                -      65     +65
PAD                                                    -      64     +64
_HMAC_SHA256_Final                                     -      55     +55
static.cpu_to_be32_vect                                -      51     +51
free_region                                            -      47     +47
libcperciva_SHA256_Init                                -      37     +37
yescrypt_init_local                                    -      34     +34
crypt_make_pw_salt                                    92     125     +33
initial_state                                          -      32     +32
.rodata                                           105771  105803     +32
atoi64                                                 -      25     +25
explicit_bzero                                         -      22     +22
pw_encrypt                                           920     941     +21
yescrypt_free_local                                    -       9      +9
crypt_make_salt                                       85       -     -85
------------------------------------------------------------------------------
(add/remove: 43/1 grow/shrink: 3/0 up/down: 31042/-85)      Total: 30957 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2025-07-06 00:49:22 +02:00
Denys Vlasenko
a26711a2d1 libbb: consolidate NOMMU fix of restoring high bit in argv[0][0]
function                                             old     new   delta
fork_or_rexec                                         46      56     +10
bootchartd_main                                     1087    1079      -8
cpio_main                                            674     661     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-21)            Total: -11 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-04-06 21:20:28 +02:00
Denys Vlasenko
3253d7fe00 httpd: do not mangle cgi-bin/SCRIPT/params URLs
If cgi-bin/ prefix is seen, do not test the rest for existence,
whether it's a dir, and such.

function                                             old     new   delta
handle_incoming_and_exit                            2200    2212     +12

Reported here:
https://lists.zx2c4.com/pipermail/cgit/2023-March/004825.html

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-03-28 18:56:08 +02:00
Denys Vlasenko
c2788f88f4 libbb: introduce and use chdir_or_warn()
function                                             old     new   delta
chdir_or_warn                                          -      37     +37
send_cgi_and_exit                                    720     711      -9
xchdir                                                27      15     -12
setup_environment                                    233     217     -16
fork_job                                             449     433     -16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/4 up/down: 37/-53)            Total: -16 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-13 12:56:10 +01:00
Denys Vlasenko
97c00ae134 httpd: fix compile failure if !FEATURE_HTTPD_RANGES
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-26 14:29:37 +01:00
Denys Vlasenko
b720629dfe httpd: do not send Last-Modified / ETag / Content-Length for error pages
function                                             old     new   delta
send_headers                                         713     701     -12
send_headers_and_exit                                 20      34     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17 21:02:16 +01:00
Denys Vlasenko
70683faf38 httpd: don't send Content-Length in error pages header
function                                             old     new   delta
send_headers                                         701     713     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-17 20:37:58 +01:00
Denys Vlasenko
84874785c2 httpd: if range is not specified, correctly fall back to read/write loop
range_start was staying -1, and comparison meant to detect
"is it the first sendfile that failed, or not the first?"
was making incorrect decision. The result: nothing is sent.

function                                             old     new   delta
send_file_and_exit                                   865     877     +12

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-08 15:41:08 +02:00
Denys Vlasenko
50c5b36dd7 help: s/Don't daemonize/Run in foreground/g
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-10-08 15:02:53 +02:00
Denys Vlasenko
40f2dd7dd2 httpd: fix config deps
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-10 10:07:42 +02:00
Sergey Ponomarev
82c5eb8e46 httpd,telnetd: make default port configurable
BusyBox on Termux can't use ports less than 1024 it's patched to change default port for httpd to 8080 and telnetd to 8023.

https://github.com/termux/termux-packages/blob/master/packages/busybox/0011-networking-telnetd-default-port.patch
https://github.com/termux/termux-packages/blob/master/packages/busybox/0010-networking-httpd-default-port.patch

To avoid such patches we can make port configurable.

function                                             old     new   delta
packed_usage                                       33920   33914      -6

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-09-09 21:42:48 +02:00
Denys Vlasenko
ac4a0b3be7 httpd: add comment about faster rejection of denied IPs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-05 15:31:18 +02:00
Denys Vlasenko
ad16f89547 httpd: if no request was given at all, close the socket without generating error page
For one, an attacker can try to overload us by just opening and immediately
closing tons of connections - reduce our work to the minimum for this case.

function                                             old     new   delta
handle_incoming_and_exit                            2172    2200     +28
.rodata                                           103225  103246     +21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 49/0)               Total: 49 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-05 15:00:09 +02:00
Denys Vlasenko
91a58b207e httpd: no need to strcpy() when we only need to copy one byte
function                                             old     new   delta
handle_incoming_and_exit                            2161    2172     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-05 09:40:59 +02:00
Denys Vlasenko
5b34a5594c httpd: avoid extra stat() calls for "GET /dirname/" case
function                                             old     new   delta
parse_conf                                          1325    1332      +7
handle_incoming_and_exit                            2173    2161     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-12)              Total: -5 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-04 21:25:16 +02:00
Denys Vlasenko
1c69817885 httpd: avoid one stat() call for "GET /dirname" case
function                                             old     new   delta
handle_incoming_and_exit                            2172    2173      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-04 21:11:03 +02:00
Denys Vlasenko
32a8258be7 httpd: support HEAD requests even in !CGI config
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-04 20:15:24 +02:00
Denys Vlasenko
ff4d898fe6 httpd: move proxy check before URL duplication and request type check
This makes proxy work for any type of requests.

function                                             old     new   delta
handle_incoming_and_exit                            2240    2172     -68

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-04 19:52:41 +02:00
Alexander Sack
36e932abdf httpd: cgi-bin support for DELETE, PUT, OPTIONS etc methods
function                                             old     new   delta
handle_incoming_and_exit                            2217    2240     +23
static.request_POST                                    -       5      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 28/0)               Total: 28 bytes

Signed-off-by: Alexander Sack <asac@pantacor.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-05-04 19:20:50 +02:00
Ron Yorston
cad3fc743a libbb: introduce and use fputs_stdout
function                                             old     new   delta
fputs_stdout                                           -      12     +12
zxc_vm_process                                      7237    7230      -7
yes_main                                              85      78      -7
write_block                                          380     373      -7
wrapf                                                305     298      -7
strings_main                                         437     430      -7
show_bridge                                          353     346      -7
rev_main                                             384     377      -7
put_prompt_custom                                     58      51      -7
put_cur_glyph_and_inc_cursor                         168     161      -7
print_numbered_lines                                 152     145      -7
print_named_ascii                                    130     123      -7
print_name                                           135     128      -7
print_login_issue                                    386     379      -7
print_ascii                                          208     201      -7
powertop_main                                       1249    1242      -7
od_main                                             1789    1782      -7
logread_main                                         518     511      -7
head_main                                            804     797      -7
display_process_list                                1319    1312      -7
cut_main                                            1002     995      -7
bb_dump_dump                                        1550    1543      -7
bb_ask_noecho                                        393     386      -7
baseNUM_main                                         702     695      -7
expand_main                                          755     745     -10
dumpleases_main                                      497     487     -10
write1                                                12       -     -12
putcsi                                                37      23     -14
print_login_prompt                                    55      41     -14
paste_main                                           525     511     -14
cat_main                                             440     426     -14
print_it                                             245     230     -15
print_addrinfo                                      1188    1171     -17
print_rule                                           770     750     -20
print_linkinfo                                       842     822     -20
httpd_main                                           791     771     -20
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/34 up/down: 12/-341)         Total: -329 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-03 20:52:40 +01:00
Alex Samorukov
dae90bbcc2 Fix httpd compilation on the FreeBSD
FreeBSD is not exporting s6_addr32 by default, but has it.

Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-01-04 13:28:28 +01:00
Maxim Storchak
04e0d8e579 httpd: fix offset for sendfile
If the Range: header is not present it the request,
the offset passed to sendfile is wrong,
and httpd falls back to the read-write loop.

function                                             old     new   delta
send_file_and_exit                                   857     865      +8
handle_incoming_and_exit                            2239    2230      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 8/-9)               Total: -1 bytes

Signed-off-by: Maxim Storchak <m.storchak@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-12-29 23:03:32 +01:00
Denys Vlasenko
885121e25d libbb: change decode_base32/64 API to return the end of _dst_, not _src_.
function                                             old     new   delta
decode_base64                                        173     178      +5
read_base64                                          222     220      -2
decode_base32                                        186     182      -4
handle_incoming_and_exit                            2263    2239     -24
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 5/-30)             Total: -25 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-28 13:27:36 +01:00
Denys Vlasenko
170b8628fa libbb: smaller and faster decode_base64()
function                                             old     new   delta
decode_base64                                        195     180     -15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-27 20:45:15 +01:00
Xabier Oneca
535a509846 httpd: code shrink
Use decode_base64() from uuencode.c when uudecode/base64 applets are included.
That function is bigger than httpd's decodeBase64(), so we use the old one when
those applets are disabled. Bloat-o-meter when one of those is enabled:

function                                             old     new   delta
handle_incoming_and_exit                            2371    2265    -106

Signed-off-by: Xabier Oneca <xoneca@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-10-06 02:36:06 +02:00
Sergey Ponomarev
a949399d17 httpd: Make Deny/Allow by IP config support optional
When disabled:

function                                             old     new   delta
if_ip_denied_send_HTTP_FORBIDDEN_and_exit             52       -     -52
handle_incoming_and_exit                            2201    2097    -104
scan_ip                                              170       -    -170
parse_conf                                          1365    1065    -300
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/2 up/down: 0/-626)           Total: -626 bytes

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-16 14:58:31 +02:00
Sergey Ponomarev
4864a68596 httpd: Support caching via ETag header
If server responds with ETag then next time client can resend it via If-None-Match header.
Then httpd will check if file wasn't modified and if not return 304 Not Modified status code.
The ETag value is constructed from file's last modification date in unix epoch and it's size:
"hex(last_mod)-hex(file_size)" e.g. "5e132e20-417" (with quotes).
That means that it's not completely reliable as hash functions but fair enough.
The same form of ETag is used by Nginx so load balancing of static content is safe.

function                                             old     new   delta
handle_incoming_and_exit                            2135    2201     +66
http_response                                         88      96      +8
send_headers                                         676     683      +7
parse_conf                                          1362    1365      +3
http_response_type                                    22      24      +2
send_file_and_exit                                   847     841      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/1 up/down: 86/-6)              Total: 80 bytes

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-08-15 23:54:48 +02:00