History log of /netbsd-current/libexec/httpd/dir-index-bozo.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.37 26-Apr-2024 maya

Create mobile-friendly directory listings

A typical mobile browser on a smartphone assumes a page without a "viewport"
<meta> tag is designed for desktop browsers. It displays the page in a
virtual window that simulates a wider screen and does not adjust it for
the phone's pixel density. The usual result is that the content on the page
looks small, and interacting with the page comfortably and precisely requires
zoom. This is currently the case with bozohttpd directory listing pages.

from D. Bohdan in PR bin/57962


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 bozohttpd-20240126 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base bozohttpd-20220517
# 1.36 18-May-2022 mrg

call this bozohttpd 20220517.


# 1.35 14-Mar-2022 mrg

check for scandir() returning -1. should handle PR#56358.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base bozohttpd-20210227 bozohttpd-20201014
# 1.34 15-Oct-2020 mrg

set -D_GNU_SOURCE in Makefile.boot. from hadrien.lacour@posteo.net.
also match %2F as well as %2f. from leah@vuxu.org.
introduce defines for "80" and "443". copyright maint.


Revision tags: bozohttpd-20200820
# 1.33 06-Jul-2020 jmcneill

Add -R flag to specify a README file to add at the bottom of directory
autoindex listings.


Revision tags: netbsd-9-1-RELEASE bozohttpd-20190228 phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.32 28-Feb-2019 mrg

branches: 1.32.2;
add ssl specific timeout value (30s). if SSL_accept() doesn't
work with in this timeout value, ssl setup now fails.

mostly different from, but inspired from the patch in PR 50655


Revision tags: pgoyette-compat-20190127
# 1.31 22-Jan-2019 mrg

o don't display special files in the directory index. they aren't
served, but links to them are generated.


Revision tags: pgoyette-compat-20190118
# 1.30 17-Jan-2019 mrg

- call this 20190116
- adjust the directory indexing again:
- don't include "index.html" in html headers
- additional escaping of names
- re-add top/bottom borders
- adds an aquamarine table header
- Zebra-stripes table rows using CSS instead of code
all from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>


Revision tags: pgoyette-compat-1226
# 1.29 04-Dec-2018 mrg

use html tables for directory index.
from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>

call this bozohttpd 20181204.


Revision tags: pgoyette-compat-1126 bozohttpd-20181125 bozohttpd-20181123
# 1.28 22-Nov-2018 mrg

many clean ups:
- keep a list of special files and their human names
- remove (void) casts on bozo_http_error()
- fix a few more misuses of bozo_http_error()
- rename check_mapping() to check_remap() and perform some CSE
- switch away from ``%s'' to '%s'
- remove a bunch of #ifdef using new have_feature defines


Revision tags: bozohttpd-20181121
# 1.27 21-Nov-2018 mrg

two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate. now 10000 byte files say 10kB not 9kB.


# 1.26 20-Nov-2018 mrg

from CHANGES:

o reduce default timeouts, and add expand timeouts to handle the
initial line, each header, and the total time spent
o add -T option to expose new timeout settings
o minor RFC fixes related to timeout handling responses

old timeouts:
60 seconds for initial request like, 60 seconds per header line,
and no whole timeout (though the recent total header size changes
do introduce one that would be about 11 hours.)
new timeouts:
30 seconds for initial request like, 10 seconds per header line,
and a total request time of 600 seconds.


the new global timeout is implemented using CLOCK_MONOTONIC, with
a fallback to CLOCK_REALTIME if monotonic time is unavailable.


reject multiple Host: headers. besides being protocol standard,
this closes one additional memory leak found by JP. add a simple
test to check this.


clean up option and usage handling some.


Revision tags: bozohttpd-20181118 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.25 29-Dec-2015 mrg

branches: 1.25.8; 1.25.14; 1.25.16;
- convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
and remove the 'username' member of bozohttpd_t since it is not
used outside of bozo_setup().


# 1.24 28-Dec-2015 mrg

rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.


# 1.23 27-Dec-2015 mrg

several clean ups:

- bozostrdup() gains a request parameter, and uses it to determine
what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
but i'm only guessing here.


# 1.22 28-Oct-2015 shm

* add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@


# 1.21 27-Aug-2015 mrg

s/dirname/dirpath/ to avoid potentially shadowing dirname(3).


Revision tags: bozohttpd-20150320 bozohttpd-20141225
# 1.20 10-Oct-2014 mrg

don't truncate file sizes to 32 bits for directory indexes.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 bozohttpd-20140102 tls-maxphys-base
# 1.19 02-Jan-2014 mrg

branches: 1.19.4;
- update CHANGES with recent changes
- update version to 20140102
- update copyrights
- use getcwd() over getwd()
- fix lean build (don't include lua)


# 1.18 12-Oct-2013 mbalmer

no need to check free() arguments against NULL


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base bozohttpd-20130711
# 1.17 11-Jul-2013 mrg

copyright maint.


# 1.16 11-Jul-2013 mrg

- update CHANGES with recent changes
- export esacpe_html() and use it in directory indexing
- update manual to include recent contributors


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.15 19-Jul-2012 mrg

branches: 1.15.2;
when generating URIs escape various characters as specified in RFC 3986.
this makes, among other things, files/dirs with "?" work with dir indexing.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.14 29-Feb-2012 joerg

Avoid using computed string as format string, just print it as string.


Revision tags: netbsd-6-base
# 1.13 18-Nov-2011 mrg

branches: 1.13.2;
merge bozohttpd 20111118


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.12 10-Mar-2011 reed

branches: 1.12.4;
A filename with a colon in it made it appear to be the URI scheme
to various web browsers. So follow RFC 3986 4.2 and prepend ./
to the filename in the generated index hyperlink.

Okayed by mrg.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.11 20-Sep-2010 mrg

merge bozohttpd 20100920


# 1.10 16-Aug-2010 dogcow

...and free() memory malloc()ed by scandir so we don't leak.


# 1.9 16-Aug-2010 dogcow

readdir -> scandir and requisite changes, so that bozohttpd now sorts
directory listings.


# 1.8 10-May-2010 mrg

merge bozohttpd 20100509.


Revision tags: matt-premerge-20091211
# 1.7 04-Nov-2009 joerg

Do not indent global variables.


Revision tags: jym-xensuspend-nbase mrg-merged-to-bozohttpd-20090417-post jym-xensuspend-base
# 1.6 18-Apr-2009 mrg

merge bozohttpd 20090417


# 1.5 04-Feb-2009 tls

branches: 1.5.2;
From Sergey Katsev at Coyote Point: fix bugs in request transformation and
CGI handling, including bin/40355 . There are two main changes here:

1) call process_cgi() after transform_request(), not before. Now it is
possible to have a default cgi handler catch a request for a path that
was produced by transformation, e.g. by index generation -- so now the
index can be "generated" by a CGI if that is what the user desires.

2) More clearly distinguish "file" from "query" portions of the request
URL, so we do not feed ?-suffixed "arguments" to plain files, fail to
match filename extensions due to ?-suffixes, etc.

After this change, there are only two cases which use the "query"
portion of the request (the portion after the ?):

a) A redirect issued by HTTPD will redirect to the new file, but
with the same query string.

b) process_cgi() will, of course continue to use the query string.


Revision tags: netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.4 03-Mar-2008 mrg

branches: 1.4.8;
merge bozohttpd 20080303


Revision tags: mrg-merged-to-bozohttpd-20080303 cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.3 18-Oct-2007 ad

branches: 1.3.2; 1.3.6;
Make the dir indexes less ugly (horizontal rules were out of place).


# 1.2 17-Oct-2007 tls

RCS IDs


# 1.1 16-Oct-2007 tls

branches: 1.1.1;
Initial revision


Revision tags: bozohttpd-20220517
# 1.36 18-May-2022 mrg

call this bozohttpd 20220517.


# 1.35 14-Mar-2022 mrg

check for scandir() returning -1. should handle PR#56358.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base bozohttpd-20210227 bozohttpd-20201014
# 1.34 15-Oct-2020 mrg

set -D_GNU_SOURCE in Makefile.boot. from hadrien.lacour@posteo.net.
also match %2F as well as %2f. from leah@vuxu.org.
introduce defines for "80" and "443". copyright maint.


Revision tags: bozohttpd-20200820
# 1.33 06-Jul-2020 jmcneill

Add -R flag to specify a README file to add at the bottom of directory
autoindex listings.


Revision tags: netbsd-9-1-RELEASE bozohttpd-20190228 phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.32 28-Feb-2019 mrg

branches: 1.32.2;
add ssl specific timeout value (30s). if SSL_accept() doesn't
work with in this timeout value, ssl setup now fails.

mostly different from, but inspired from the patch in PR 50655


Revision tags: pgoyette-compat-20190127
# 1.31 22-Jan-2019 mrg

o don't display special files in the directory index. they aren't
served, but links to them are generated.


Revision tags: pgoyette-compat-20190118
# 1.30 17-Jan-2019 mrg

- call this 20190116
- adjust the directory indexing again:
- don't include "index.html" in html headers
- additional escaping of names
- re-add top/bottom borders
- adds an aquamarine table header
- Zebra-stripes table rows using CSS instead of code
all from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>


Revision tags: pgoyette-compat-1226
# 1.29 04-Dec-2018 mrg

use html tables for directory index.
from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>

call this bozohttpd 20181204.


Revision tags: pgoyette-compat-1126 bozohttpd-20181125 bozohttpd-20181123
# 1.28 22-Nov-2018 mrg

many clean ups:
- keep a list of special files and their human names
- remove (void) casts on bozo_http_error()
- fix a few more misuses of bozo_http_error()
- rename check_mapping() to check_remap() and perform some CSE
- switch away from ``%s'' to '%s'
- remove a bunch of #ifdef using new have_feature defines


Revision tags: bozohttpd-20181121
# 1.27 21-Nov-2018 mrg

two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate. now 10000 byte files say 10kB not 9kB.


# 1.26 20-Nov-2018 mrg

from CHANGES:

o reduce default timeouts, and add expand timeouts to handle the
initial line, each header, and the total time spent
o add -T option to expose new timeout settings
o minor RFC fixes related to timeout handling responses

old timeouts:
60 seconds for initial request like, 60 seconds per header line,
and no whole timeout (though the recent total header size changes
do introduce one that would be about 11 hours.)
new timeouts:
30 seconds for initial request like, 10 seconds per header line,
and a total request time of 600 seconds.


the new global timeout is implemented using CLOCK_MONOTONIC, with
a fallback to CLOCK_REALTIME if monotonic time is unavailable.


reject multiple Host: headers. besides being protocol standard,
this closes one additional memory leak found by JP. add a simple
test to check this.


clean up option and usage handling some.


Revision tags: bozohttpd-20181118 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.25 29-Dec-2015 mrg

branches: 1.25.8; 1.25.14; 1.25.16;
- convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
and remove the 'username' member of bozohttpd_t since it is not
used outside of bozo_setup().


# 1.24 28-Dec-2015 mrg

rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.


# 1.23 27-Dec-2015 mrg

several clean ups:

- bozostrdup() gains a request parameter, and uses it to determine
what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
but i'm only guessing here.


# 1.22 28-Oct-2015 shm

* add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@


# 1.21 27-Aug-2015 mrg

s/dirname/dirpath/ to avoid potentially shadowing dirname(3).


Revision tags: bozohttpd-20150320 bozohttpd-20141225
# 1.20 10-Oct-2014 mrg

don't truncate file sizes to 32 bits for directory indexes.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 bozohttpd-20140102 tls-maxphys-base
# 1.19 02-Jan-2014 mrg

branches: 1.19.4;
- update CHANGES with recent changes
- update version to 20140102
- update copyrights
- use getcwd() over getwd()
- fix lean build (don't include lua)


# 1.18 12-Oct-2013 mbalmer

no need to check free() arguments against NULL


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base bozohttpd-20130711
# 1.17 11-Jul-2013 mrg

copyright maint.


# 1.16 11-Jul-2013 mrg

- update CHANGES with recent changes
- export esacpe_html() and use it in directory indexing
- update manual to include recent contributors


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.15 19-Jul-2012 mrg

branches: 1.15.2;
when generating URIs escape various characters as specified in RFC 3986.
this makes, among other things, files/dirs with "?" work with dir indexing.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.14 29-Feb-2012 joerg

Avoid using computed string as format string, just print it as string.


Revision tags: netbsd-6-base
# 1.13 18-Nov-2011 mrg

branches: 1.13.2;
merge bozohttpd 20111118


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.12 10-Mar-2011 reed

branches: 1.12.4;
A filename with a colon in it made it appear to be the URI scheme
to various web browsers. So follow RFC 3986 4.2 and prepend ./
to the filename in the generated index hyperlink.

Okayed by mrg.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.11 20-Sep-2010 mrg

merge bozohttpd 20100920


# 1.10 16-Aug-2010 dogcow

...and free() memory malloc()ed by scandir so we don't leak.


# 1.9 16-Aug-2010 dogcow

readdir -> scandir and requisite changes, so that bozohttpd now sorts
directory listings.


# 1.8 10-May-2010 mrg

merge bozohttpd 20100509.


Revision tags: matt-premerge-20091211
# 1.7 04-Nov-2009 joerg

Do not indent global variables.


Revision tags: jym-xensuspend-nbase mrg-merged-to-bozohttpd-20090417-post jym-xensuspend-base
# 1.6 18-Apr-2009 mrg

merge bozohttpd 20090417


# 1.5 04-Feb-2009 tls

branches: 1.5.2;
From Sergey Katsev at Coyote Point: fix bugs in request transformation and
CGI handling, including bin/40355 . There are two main changes here:

1) call process_cgi() after transform_request(), not before. Now it is
possible to have a default cgi handler catch a request for a path that
was produced by transformation, e.g. by index generation -- so now the
index can be "generated" by a CGI if that is what the user desires.

2) More clearly distinguish "file" from "query" portions of the request
URL, so we do not feed ?-suffixed "arguments" to plain files, fail to
match filename extensions due to ?-suffixes, etc.

After this change, there are only two cases which use the "query"
portion of the request (the portion after the ?):

a) A redirect issued by HTTPD will redirect to the new file, but
with the same query string.

b) process_cgi() will, of course continue to use the query string.


Revision tags: netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.4 03-Mar-2008 mrg

branches: 1.4.8;
merge bozohttpd 20080303


Revision tags: mrg-merged-to-bozohttpd-20080303 cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.3 18-Oct-2007 ad

branches: 1.3.2; 1.3.6;
Make the dir indexes less ugly (horizontal rules were out of place).


# 1.2 17-Oct-2007 tls

RCS IDs


# 1.1 16-Oct-2007 tls

branches: 1.1.1;
Initial revision


# 1.35 14-Mar-2022 mrg

check for scandir() returning -1. should handle PR#56358.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base bozohttpd-20210227 bozohttpd-20201014
# 1.34 15-Oct-2020 mrg

set -D_GNU_SOURCE in Makefile.boot. from hadrien.lacour@posteo.net.
also match %2F as well as %2f. from leah@vuxu.org.
introduce defines for "80" and "443". copyright maint.


Revision tags: bozohttpd-20200820
# 1.33 06-Jul-2020 jmcneill

Add -R flag to specify a README file to add at the bottom of directory
autoindex listings.


Revision tags: netbsd-9-1-RELEASE bozohttpd-20190228 phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.32 28-Feb-2019 mrg

branches: 1.32.2;
add ssl specific timeout value (30s). if SSL_accept() doesn't
work with in this timeout value, ssl setup now fails.

mostly different from, but inspired from the patch in PR 50655


Revision tags: pgoyette-compat-20190127
# 1.31 22-Jan-2019 mrg

o don't display special files in the directory index. they aren't
served, but links to them are generated.


Revision tags: pgoyette-compat-20190118
# 1.30 17-Jan-2019 mrg

- call this 20190116
- adjust the directory indexing again:
- don't include "index.html" in html headers
- additional escaping of names
- re-add top/bottom borders
- adds an aquamarine table header
- Zebra-stripes table rows using CSS instead of code
all from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>


Revision tags: pgoyette-compat-1226
# 1.29 04-Dec-2018 mrg

use html tables for directory index.
from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>

call this bozohttpd 20181204.


Revision tags: pgoyette-compat-1126 bozohttpd-20181125 bozohttpd-20181123
# 1.28 22-Nov-2018 mrg

many clean ups:
- keep a list of special files and their human names
- remove (void) casts on bozo_http_error()
- fix a few more misuses of bozo_http_error()
- rename check_mapping() to check_remap() and perform some CSE
- switch away from ``%s'' to '%s'
- remove a bunch of #ifdef using new have_feature defines


Revision tags: bozohttpd-20181121
# 1.27 21-Nov-2018 mrg

two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate. now 10000 byte files say 10kB not 9kB.


# 1.26 20-Nov-2018 mrg

from CHANGES:

o reduce default timeouts, and add expand timeouts to handle the
initial line, each header, and the total time spent
o add -T option to expose new timeout settings
o minor RFC fixes related to timeout handling responses

old timeouts:
60 seconds for initial request like, 60 seconds per header line,
and no whole timeout (though the recent total header size changes
do introduce one that would be about 11 hours.)
new timeouts:
30 seconds for initial request like, 10 seconds per header line,
and a total request time of 600 seconds.


the new global timeout is implemented using CLOCK_MONOTONIC, with
a fallback to CLOCK_REALTIME if monotonic time is unavailable.


reject multiple Host: headers. besides being protocol standard,
this closes one additional memory leak found by JP. add a simple
test to check this.


clean up option and usage handling some.


Revision tags: bozohttpd-20181118 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.25 29-Dec-2015 mrg

branches: 1.25.8; 1.25.14; 1.25.16;
- convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
and remove the 'username' member of bozohttpd_t since it is not
used outside of bozo_setup().


# 1.24 28-Dec-2015 mrg

rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.


# 1.23 27-Dec-2015 mrg

several clean ups:

- bozostrdup() gains a request parameter, and uses it to determine
what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
but i'm only guessing here.


# 1.22 28-Oct-2015 shm

* add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@


# 1.21 27-Aug-2015 mrg

s/dirname/dirpath/ to avoid potentially shadowing dirname(3).


Revision tags: bozohttpd-20150320 bozohttpd-20141225
# 1.20 10-Oct-2014 mrg

don't truncate file sizes to 32 bits for directory indexes.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 bozohttpd-20140102 tls-maxphys-base
# 1.19 02-Jan-2014 mrg

branches: 1.19.4;
- update CHANGES with recent changes
- update version to 20140102
- update copyrights
- use getcwd() over getwd()
- fix lean build (don't include lua)


# 1.18 12-Oct-2013 mbalmer

no need to check free() arguments against NULL


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base bozohttpd-20130711
# 1.17 11-Jul-2013 mrg

copyright maint.


# 1.16 11-Jul-2013 mrg

- update CHANGES with recent changes
- export esacpe_html() and use it in directory indexing
- update manual to include recent contributors


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.15 19-Jul-2012 mrg

branches: 1.15.2;
when generating URIs escape various characters as specified in RFC 3986.
this makes, among other things, files/dirs with "?" work with dir indexing.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.14 29-Feb-2012 joerg

Avoid using computed string as format string, just print it as string.


Revision tags: netbsd-6-base
# 1.13 18-Nov-2011 mrg

branches: 1.13.2;
merge bozohttpd 20111118


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.12 10-Mar-2011 reed

branches: 1.12.4;
A filename with a colon in it made it appear to be the URI scheme
to various web browsers. So follow RFC 3986 4.2 and prepend ./
to the filename in the generated index hyperlink.

Okayed by mrg.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.11 20-Sep-2010 mrg

merge bozohttpd 20100920


# 1.10 16-Aug-2010 dogcow

...and free() memory malloc()ed by scandir so we don't leak.


# 1.9 16-Aug-2010 dogcow

readdir -> scandir and requisite changes, so that bozohttpd now sorts
directory listings.


# 1.8 10-May-2010 mrg

merge bozohttpd 20100509.


Revision tags: matt-premerge-20091211
# 1.7 04-Nov-2009 joerg

Do not indent global variables.


Revision tags: jym-xensuspend-nbase mrg-merged-to-bozohttpd-20090417-post jym-xensuspend-base
# 1.6 18-Apr-2009 mrg

merge bozohttpd 20090417


# 1.5 04-Feb-2009 tls

branches: 1.5.2;
From Sergey Katsev at Coyote Point: fix bugs in request transformation and
CGI handling, including bin/40355 . There are two main changes here:

1) call process_cgi() after transform_request(), not before. Now it is
possible to have a default cgi handler catch a request for a path that
was produced by transformation, e.g. by index generation -- so now the
index can be "generated" by a CGI if that is what the user desires.

2) More clearly distinguish "file" from "query" portions of the request
URL, so we do not feed ?-suffixed "arguments" to plain files, fail to
match filename extensions due to ?-suffixes, etc.

After this change, there are only two cases which use the "query"
portion of the request (the portion after the ?):

a) A redirect issued by HTTPD will redirect to the new file, but
with the same query string.

b) process_cgi() will, of course continue to use the query string.


Revision tags: netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.4 03-Mar-2008 mrg

branches: 1.4.8;
merge bozohttpd 20080303


Revision tags: mrg-merged-to-bozohttpd-20080303 cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.3 18-Oct-2007 ad

branches: 1.3.2; 1.3.6;
Make the dir indexes less ugly (horizontal rules were out of place).


# 1.2 17-Oct-2007 tls

RCS IDs


# 1.1 16-Oct-2007 tls

branches: 1.1.1;
Initial revision


Revision tags: bozohttpd-20201014
# 1.34 15-Oct-2020 mrg

set -D_GNU_SOURCE in Makefile.boot. from hadrien.lacour@posteo.net.
also match %2F as well as %2f. from leah@vuxu.org.
introduce defines for "80" and "443". copyright maint.


Revision tags: bozohttpd-20200820
# 1.33 06-Jul-2020 jmcneill

Add -R flag to specify a README file to add at the bottom of directory
autoindex listings.


Revision tags: netbsd-9-1-RELEASE bozohttpd-20190228 phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.32 28-Feb-2019 mrg

add ssl specific timeout value (30s). if SSL_accept() doesn't
work with in this timeout value, ssl setup now fails.

mostly different from, but inspired from the patch in PR 50655


Revision tags: pgoyette-compat-20190127
# 1.31 22-Jan-2019 mrg

o don't display special files in the directory index. they aren't
served, but links to them are generated.


Revision tags: pgoyette-compat-20190118
# 1.30 17-Jan-2019 mrg

- call this 20190116
- adjust the directory indexing again:
- don't include "index.html" in html headers
- additional escaping of names
- re-add top/bottom borders
- adds an aquamarine table header
- Zebra-stripes table rows using CSS instead of code
all from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>


Revision tags: pgoyette-compat-1226
# 1.29 04-Dec-2018 mrg

use html tables for directory index.
from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>

call this bozohttpd 20181204.


Revision tags: pgoyette-compat-1126 bozohttpd-20181125 bozohttpd-20181123
# 1.28 22-Nov-2018 mrg

many clean ups:
- keep a list of special files and their human names
- remove (void) casts on bozo_http_error()
- fix a few more misuses of bozo_http_error()
- rename check_mapping() to check_remap() and perform some CSE
- switch away from ``%s'' to '%s'
- remove a bunch of #ifdef using new have_feature defines


Revision tags: bozohttpd-20181121
# 1.27 21-Nov-2018 mrg

two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate. now 10000 byte files say 10kB not 9kB.


# 1.26 20-Nov-2018 mrg

from CHANGES:

o reduce default timeouts, and add expand timeouts to handle the
initial line, each header, and the total time spent
o add -T option to expose new timeout settings
o minor RFC fixes related to timeout handling responses

old timeouts:
60 seconds for initial request like, 60 seconds per header line,
and no whole timeout (though the recent total header size changes
do introduce one that would be about 11 hours.)
new timeouts:
30 seconds for initial request like, 10 seconds per header line,
and a total request time of 600 seconds.


the new global timeout is implemented using CLOCK_MONOTONIC, with
a fallback to CLOCK_REALTIME if monotonic time is unavailable.


reject multiple Host: headers. besides being protocol standard,
this closes one additional memory leak found by JP. add a simple
test to check this.


clean up option and usage handling some.


Revision tags: bozohttpd-20181118 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.25 29-Dec-2015 mrg

branches: 1.25.8; 1.25.14; 1.25.16;
- convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
and remove the 'username' member of bozohttpd_t since it is not
used outside of bozo_setup().


# 1.24 28-Dec-2015 mrg

rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.


# 1.23 27-Dec-2015 mrg

several clean ups:

- bozostrdup() gains a request parameter, and uses it to determine
what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
but i'm only guessing here.


# 1.22 28-Oct-2015 shm

* add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@


# 1.21 27-Aug-2015 mrg

s/dirname/dirpath/ to avoid potentially shadowing dirname(3).


Revision tags: bozohttpd-20150320 bozohttpd-20141225
# 1.20 10-Oct-2014 mrg

don't truncate file sizes to 32 bits for directory indexes.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 bozohttpd-20140102 tls-maxphys-base
# 1.19 02-Jan-2014 mrg

branches: 1.19.4;
- update CHANGES with recent changes
- update version to 20140102
- update copyrights
- use getcwd() over getwd()
- fix lean build (don't include lua)


# 1.18 12-Oct-2013 mbalmer

no need to check free() arguments against NULL


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base bozohttpd-20130711
# 1.17 11-Jul-2013 mrg

copyright maint.


# 1.16 11-Jul-2013 mrg

- update CHANGES with recent changes
- export esacpe_html() and use it in directory indexing
- update manual to include recent contributors


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.15 19-Jul-2012 mrg

branches: 1.15.2;
when generating URIs escape various characters as specified in RFC 3986.
this makes, among other things, files/dirs with "?" work with dir indexing.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.14 29-Feb-2012 joerg

Avoid using computed string as format string, just print it as string.


Revision tags: netbsd-6-base
# 1.13 18-Nov-2011 mrg

branches: 1.13.2;
merge bozohttpd 20111118


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.12 10-Mar-2011 reed

branches: 1.12.4;
A filename with a colon in it made it appear to be the URI scheme
to various web browsers. So follow RFC 3986 4.2 and prepend ./
to the filename in the generated index hyperlink.

Okayed by mrg.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.11 20-Sep-2010 mrg

merge bozohttpd 20100920


# 1.10 16-Aug-2010 dogcow

...and free() memory malloc()ed by scandir so we don't leak.


# 1.9 16-Aug-2010 dogcow

readdir -> scandir and requisite changes, so that bozohttpd now sorts
directory listings.


# 1.8 10-May-2010 mrg

merge bozohttpd 20100509.


Revision tags: matt-premerge-20091211
# 1.7 04-Nov-2009 joerg

Do not indent global variables.


Revision tags: jym-xensuspend-nbase mrg-merged-to-bozohttpd-20090417-post jym-xensuspend-base
# 1.6 18-Apr-2009 mrg

merge bozohttpd 20090417


# 1.5 04-Feb-2009 tls

branches: 1.5.2;
From Sergey Katsev at Coyote Point: fix bugs in request transformation and
CGI handling, including bin/40355 . There are two main changes here:

1) call process_cgi() after transform_request(), not before. Now it is
possible to have a default cgi handler catch a request for a path that
was produced by transformation, e.g. by index generation -- so now the
index can be "generated" by a CGI if that is what the user desires.

2) More clearly distinguish "file" from "query" portions of the request
URL, so we do not feed ?-suffixed "arguments" to plain files, fail to
match filename extensions due to ?-suffixes, etc.

After this change, there are only two cases which use the "query"
portion of the request (the portion after the ?):

a) A redirect issued by HTTPD will redirect to the new file, but
with the same query string.

b) process_cgi() will, of course continue to use the query string.


Revision tags: netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.4 03-Mar-2008 mrg

branches: 1.4.8;
merge bozohttpd 20080303


Revision tags: mrg-merged-to-bozohttpd-20080303 cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.3 18-Oct-2007 ad

branches: 1.3.2; 1.3.6;
Make the dir indexes less ugly (horizontal rules were out of place).


# 1.2 17-Oct-2007 tls

RCS IDs


# 1.1 16-Oct-2007 tls

branches: 1.1.1;
Initial revision


# 1.33 06-Jul-2020 jmcneill

Add -R flag to specify a README file to add at the bottom of directory
autoindex listings.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.32 28-Feb-2019 mrg

add ssl specific timeout value (30s). if SSL_accept() doesn't
work with in this timeout value, ssl setup now fails.

mostly different from, but inspired from the patch in PR 50655


Revision tags: pgoyette-compat-20190127
# 1.31 22-Jan-2019 mrg

o don't display special files in the directory index. they aren't
served, but links to them are generated.


Revision tags: pgoyette-compat-20190118
# 1.30 17-Jan-2019 mrg

- call this 20190116
- adjust the directory indexing again:
- don't include "index.html" in html headers
- additional escaping of names
- re-add top/bottom borders
- adds an aquamarine table header
- Zebra-stripes table rows using CSS instead of code
all from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>


Revision tags: pgoyette-compat-1226
# 1.29 04-Dec-2018 mrg

use html tables for directory index.
from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>

call this bozohttpd 20181204.


Revision tags: pgoyette-compat-1126 bozohttpd-20181125 bozohttpd-20181123
# 1.28 22-Nov-2018 mrg

many clean ups:
- keep a list of special files and their human names
- remove (void) casts on bozo_http_error()
- fix a few more misuses of bozo_http_error()
- rename check_mapping() to check_remap() and perform some CSE
- switch away from ``%s'' to '%s'
- remove a bunch of #ifdef using new have_feature defines


Revision tags: bozohttpd-20181121
# 1.27 21-Nov-2018 mrg

two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate. now 10000 byte files say 10kB not 9kB.


# 1.26 20-Nov-2018 mrg

from CHANGES:

o reduce default timeouts, and add expand timeouts to handle the
initial line, each header, and the total time spent
o add -T option to expose new timeout settings
o minor RFC fixes related to timeout handling responses

old timeouts:
60 seconds for initial request like, 60 seconds per header line,
and no whole timeout (though the recent total header size changes
do introduce one that would be about 11 hours.)
new timeouts:
30 seconds for initial request like, 10 seconds per header line,
and a total request time of 600 seconds.


the new global timeout is implemented using CLOCK_MONOTONIC, with
a fallback to CLOCK_REALTIME if monotonic time is unavailable.


reject multiple Host: headers. besides being protocol standard,
this closes one additional memory leak found by JP. add a simple
test to check this.


clean up option and usage handling some.


Revision tags: bozohttpd-20181118 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.25 29-Dec-2015 mrg

branches: 1.25.8; 1.25.14; 1.25.16;
- convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
and remove the 'username' member of bozohttpd_t since it is not
used outside of bozo_setup().


# 1.24 28-Dec-2015 mrg

rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.


# 1.23 27-Dec-2015 mrg

several clean ups:

- bozostrdup() gains a request parameter, and uses it to determine
what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
but i'm only guessing here.


# 1.22 28-Oct-2015 shm

* add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@


# 1.21 27-Aug-2015 mrg

s/dirname/dirpath/ to avoid potentially shadowing dirname(3).


Revision tags: bozohttpd-20150320 bozohttpd-20141225
# 1.20 10-Oct-2014 mrg

don't truncate file sizes to 32 bits for directory indexes.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 bozohttpd-20140102 tls-maxphys-base
# 1.19 02-Jan-2014 mrg

branches: 1.19.4;
- update CHANGES with recent changes
- update version to 20140102
- update copyrights
- use getcwd() over getwd()
- fix lean build (don't include lua)


# 1.18 12-Oct-2013 mbalmer

no need to check free() arguments against NULL


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base bozohttpd-20130711
# 1.17 11-Jul-2013 mrg

copyright maint.


# 1.16 11-Jul-2013 mrg

- update CHANGES with recent changes
- export esacpe_html() and use it in directory indexing
- update manual to include recent contributors


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.15 19-Jul-2012 mrg

branches: 1.15.2;
when generating URIs escape various characters as specified in RFC 3986.
this makes, among other things, files/dirs with "?" work with dir indexing.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.14 29-Feb-2012 joerg

Avoid using computed string as format string, just print it as string.


Revision tags: netbsd-6-base
# 1.13 18-Nov-2011 mrg

branches: 1.13.2;
merge bozohttpd 20111118


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.12 10-Mar-2011 reed

branches: 1.12.4;
A filename with a colon in it made it appear to be the URI scheme
to various web browsers. So follow RFC 3986 4.2 and prepend ./
to the filename in the generated index hyperlink.

Okayed by mrg.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.11 20-Sep-2010 mrg

merge bozohttpd 20100920


# 1.10 16-Aug-2010 dogcow

...and free() memory malloc()ed by scandir so we don't leak.


# 1.9 16-Aug-2010 dogcow

readdir -> scandir and requisite changes, so that bozohttpd now sorts
directory listings.


# 1.8 10-May-2010 mrg

merge bozohttpd 20100509.


Revision tags: matt-premerge-20091211
# 1.7 04-Nov-2009 joerg

Do not indent global variables.


Revision tags: jym-xensuspend-nbase mrg-merged-to-bozohttpd-20090417-post jym-xensuspend-base
# 1.6 18-Apr-2009 mrg

merge bozohttpd 20090417


# 1.5 04-Feb-2009 tls

branches: 1.5.2;
From Sergey Katsev at Coyote Point: fix bugs in request transformation and
CGI handling, including bin/40355 . There are two main changes here:

1) call process_cgi() after transform_request(), not before. Now it is
possible to have a default cgi handler catch a request for a path that
was produced by transformation, e.g. by index generation -- so now the
index can be "generated" by a CGI if that is what the user desires.

2) More clearly distinguish "file" from "query" portions of the request
URL, so we do not feed ?-suffixed "arguments" to plain files, fail to
match filename extensions due to ?-suffixes, etc.

After this change, there are only two cases which use the "query"
portion of the request (the portion after the ?):

a) A redirect issued by HTTPD will redirect to the new file, but
with the same query string.

b) process_cgi() will, of course continue to use the query string.


Revision tags: netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.4 03-Mar-2008 mrg

branches: 1.4.8;
merge bozohttpd 20080303


Revision tags: mrg-merged-to-bozohttpd-20080303 cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.3 18-Oct-2007 ad

branches: 1.3.2; 1.3.6;
Make the dir indexes less ugly (horizontal rules were out of place).


# 1.2 17-Oct-2007 tls

RCS IDs


# 1.1 16-Oct-2007 tls

branches: 1.1.1;
Initial revision


# 1.32 28-Feb-2019 mrg

add ssl specific timeout value (30s). if SSL_accept() doesn't
work with in this timeout value, ssl setup now fails.

mostly different from, but inspired from the patch in PR 50655


Revision tags: pgoyette-compat-20190127
# 1.31 22-Jan-2019 mrg

o don't display special files in the directory index. they aren't
served, but links to them are generated.


Revision tags: pgoyette-compat-20190118
# 1.30 17-Jan-2019 mrg

- call this 20190116
- adjust the directory indexing again:
- don't include "index.html" in html headers
- additional escaping of names
- re-add top/bottom borders
- adds an aquamarine table header
- Zebra-stripes table rows using CSS instead of code
all from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>


Revision tags: pgoyette-compat-1226
# 1.29 04-Dec-2018 mrg

use html tables for directory index.
from "Rajeev V. Pillai" <rajeev_v_pillai@yahoo.com>

call this bozohttpd 20181204.


Revision tags: pgoyette-compat-1126 bozohttpd-20181125 bozohttpd-20181123
# 1.28 22-Nov-2018 mrg

many clean ups:
- keep a list of special files and their human names
- remove (void) casts on bozo_http_error()
- fix a few more misuses of bozo_http_error()
- rename check_mapping() to check_remap() and perform some CSE
- switch away from ``%s'' to '%s'
- remove a bunch of #ifdef using new have_feature defines


Revision tags: bozohttpd-20181121
# 1.27 21-Nov-2018 mrg

two fixes reported by mouse:
- don't check contents of 'st' if stat(2) failed.
- round up instead of truncate. now 10000 byte files say 10kB not 9kB.


# 1.26 20-Nov-2018 mrg

from CHANGES:

o reduce default timeouts, and add expand timeouts to handle the
initial line, each header, and the total time spent
o add -T option to expose new timeout settings
o minor RFC fixes related to timeout handling responses

old timeouts:
60 seconds for initial request like, 60 seconds per header line,
and no whole timeout (though the recent total header size changes
do introduce one that would be about 11 hours.)
new timeouts:
30 seconds for initial request like, 10 seconds per header line,
and a total request time of 600 seconds.


the new global timeout is implemented using CLOCK_MONOTONIC, with
a fallback to CLOCK_REALTIME if monotonic time is unavailable.


reject multiple Host: headers. besides being protocol standard,
this closes one additional memory leak found by JP. add a simple
test to check this.


clean up option and usage handling some.


Revision tags: bozohttpd-20181118 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.25 29-Dec-2015 mrg

branches: 1.25.8; 1.25.14;
- convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
and remove the 'username' member of bozohttpd_t since it is not
used outside of bozo_setup().


# 1.24 28-Dec-2015 mrg

rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.


# 1.23 27-Dec-2015 mrg

several clean ups:

- bozostrdup() gains a request parameter, and uses it to determine
what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
but i'm only guessing here.


# 1.22 28-Oct-2015 shm

* add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@


# 1.21 27-Aug-2015 mrg

s/dirname/dirpath/ to avoid potentially shadowing dirname(3).


Revision tags: bozohttpd-20150320 bozohttpd-20141225
# 1.20 10-Oct-2014 mrg

don't truncate file sizes to 32 bits for directory indexes.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 bozohttpd-20140102 tls-maxphys-base
# 1.19 02-Jan-2014 mrg

branches: 1.19.4;
- update CHANGES with recent changes
- update version to 20140102
- update copyrights
- use getcwd() over getwd()
- fix lean build (don't include lua)


# 1.18 12-Oct-2013 mbalmer

no need to check free() arguments against NULL


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base bozohttpd-20130711
# 1.17 11-Jul-2013 mrg

copyright maint.


# 1.16 11-Jul-2013 mrg

- update CHANGES with recent changes
- export esacpe_html() and use it in directory indexing
- update manual to include recent contributors


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.15 19-Jul-2012 mrg

branches: 1.15.2;
when generating URIs escape various characters as specified in RFC 3986.
this makes, among other things, files/dirs with "?" work with dir indexing.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.14 29-Feb-2012 joerg

Avoid using computed string as format string, just print it as string.


Revision tags: netbsd-6-base
# 1.13 18-Nov-2011 mrg

branches: 1.13.2;
merge bozohttpd 20111118


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.12 10-Mar-2011 reed

branches: 1.12.4;
A filename with a colon in it made it appear to be the URI scheme
to various web browsers. So follow RFC 3986 4.2 and prepend ./
to the filename in the generated index hyperlink.

Okayed by mrg.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.11 20-Sep-2010 mrg

merge bozohttpd 20100920


# 1.10 16-Aug-2010 dogcow

...and free() memory malloc()ed by scandir so we don't leak.


# 1.9 16-Aug-2010 dogcow

readdir -> scandir and requisite changes, so that bozohttpd now sorts
directory listings.


# 1.8 10-May-2010 mrg

merge bozohttpd 20100509.


Revision tags: matt-premerge-20091211
# 1.7 04-Nov-2009 joerg

Do not indent global variables.


Revision tags: jym-xensuspend-nbase mrg-merged-to-bozohttpd-20090417-post jym-xensuspend-base
# 1.6 18-Apr-2009 mrg

merge bozohttpd 20090417


# 1.5 04-Feb-2009 tls

branches: 1.5.2;
From Sergey Katsev at Coyote Point: fix bugs in request transformation and
CGI handling, including bin/40355 . There are two main changes here:

1) call process_cgi() after transform_request(), not before. Now it is
possible to have a default cgi handler catch a request for a path that
was produced by transformation, e.g. by index generation -- so now the
index can be "generated" by a CGI if that is what the user desires.

2) More clearly distinguish "file" from "query" portions of the request
URL, so we do not feed ?-suffixed "arguments" to plain files, fail to
match filename extensions due to ?-suffixes, etc.

After this change, there are only two cases which use the "query"
portion of the request (the portion after the ?):

a) A redirect issued by HTTPD will redirect to the new file, but
with the same query string.

b) process_cgi() will, of course continue to use the query string.


Revision tags: netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.4 03-Mar-2008 mrg

branches: 1.4.8;
merge bozohttpd 20080303


Revision tags: mrg-merged-to-bozohttpd-20080303 cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.3 18-Oct-2007 ad

branches: 1.3.2; 1.3.6;
Make the dir indexes less ugly (horizontal rules were out of place).


# 1.2 17-Oct-2007 tls

RCS IDs


# 1.1 16-Oct-2007 tls

branches: 1.1.1;
Initial revision


Revision tags: pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.25 29-Dec-2015 mrg

- convert most asprintf() calls to bozoasprintf().
- don't call getpwuid(0) if we don't need to, or fail it it fails,
and remove the 'username' member of bozohttpd_t since it is not
used outside of bozo_setup().


# 1.24 28-Dec-2015 mrg

rename bozo_err/bozo_warn/bozo_asprintf to bozoerr/etc.
new rule is that function that mirror libc-style functions get no underscore.


# 1.23 27-Dec-2015 mrg

several clean ups:

- bozostrdup() gains a request parameter, and uses it to determine
what sort of error handling is required
- bozo_strdup() dies
- size_arrays() reduced slightly, pushing error handling into the caller
- convert to size_t for some array indices
- bozo_set_pref() and bozo_init_prefs() gain httpd parameters
- apply a bunch of manual CSE to vastly reduce the number of times the
string "request->hr_httpd" appears.
- CGI parse_header() takes a request not httpd now

XXX: lua glue updated to call bozo_init_prefs() with htttpd parameter,
but i'm only guessing here.


# 1.22 28-Oct-2015 shm

* add CGI support for ~user translation (-E switch)
* add redirects to ~user translation
* fix bugs around ~user translation
* add schema detection for absolute redirects
* fixed few memory leaks
* bunch of minor tweaks
* removed -r support
* smarter redirects

OK mrg@


# 1.21 27-Aug-2015 mrg

s/dirname/dirpath/ to avoid potentially shadowing dirname(3).


Revision tags: bozohttpd-20150320 bozohttpd-20141225
# 1.20 10-Oct-2014 mrg

don't truncate file sizes to 32 bits for directory indexes.


Revision tags: netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 bozohttpd-20140102 tls-maxphys-base
# 1.19 02-Jan-2014 mrg

branches: 1.19.4;
- update CHANGES with recent changes
- update version to 20140102
- update copyrights
- use getcwd() over getwd()
- fix lean build (don't include lua)


# 1.18 12-Oct-2013 mbalmer

no need to check free() arguments against NULL


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base bozohttpd-20130711
# 1.17 11-Jul-2013 mrg

copyright maint.


# 1.16 11-Jul-2013 mrg

- update CHANGES with recent changes
- export esacpe_html() and use it in directory indexing
- update manual to include recent contributors


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.15 19-Jul-2012 mrg

branches: 1.15.2;
when generating URIs escape various characters as specified in RFC 3986.
this makes, among other things, files/dirs with "?" work with dir indexing.


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.14 29-Feb-2012 joerg

Avoid using computed string as format string, just print it as string.


Revision tags: netbsd-6-base
# 1.13 18-Nov-2011 mrg

branches: 1.13.2;
merge bozohttpd 20111118


Revision tags: yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base
# 1.12 10-Mar-2011 reed

branches: 1.12.4;
A filename with a colon in it made it appear to be the URI scheme
to various web browsers. So follow RFC 3986 4.2 and prepend ./
to the filename in the generated index hyperlink.

Okayed by mrg.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.11 20-Sep-2010 mrg

merge bozohttpd 20100920


# 1.10 16-Aug-2010 dogcow

...and free() memory malloc()ed by scandir so we don't leak.


# 1.9 16-Aug-2010 dogcow

readdir -> scandir and requisite changes, so that bozohttpd now sorts
directory listings.


# 1.8 10-May-2010 mrg

merge bozohttpd 20100509.


Revision tags: matt-premerge-20091211
# 1.7 04-Nov-2009 joerg

Do not indent global variables.


Revision tags: jym-xensuspend-nbase mrg-merged-to-bozohttpd-20090417-post jym-xensuspend-base
# 1.6 18-Apr-2009 mrg

merge bozohttpd 20090417


# 1.5 04-Feb-2009 tls

branches: 1.5.2;
From Sergey Katsev at Coyote Point: fix bugs in request transformation and
CGI handling, including bin/40355 . There are two main changes here:

1) call process_cgi() after transform_request(), not before. Now it is
possible to have a default cgi handler catch a request for a path that
was produced by transformation, e.g. by index generation -- so now the
index can be "generated" by a CGI if that is what the user desires.

2) More clearly distinguish "file" from "query" portions of the request
URL, so we do not feed ?-suffixed "arguments" to plain files, fail to
match filename extensions due to ?-suffixes, etc.

After this change, there are only two cases which use the "query"
portion of the request (the portion after the ?):

a) A redirect issued by HTTPD will redirect to the new file, but
with the same query string.

b) process_cgi() will, of course continue to use the query string.


Revision tags: netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase
# 1.4 03-Mar-2008 mrg

branches: 1.4.8;
merge bozohttpd 20080303


Revision tags: mrg-merged-to-bozohttpd-20080303 cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.3 18-Oct-2007 ad

branches: 1.3.2; 1.3.6;
Make the dir indexes less ugly (horizontal rules were out of place).


# 1.2 17-Oct-2007 tls

RCS IDs


# 1.1 16-Oct-2007 tls

branches: 1.1.1;
Initial revision