head 1.5; access; symbols bozohttpd-20260503:1.5 bozohttpd-20240428:1.5 netbsd-11-0-RC3:1.5 netbsd-11-0-RC2:1.5 netbsd-11-0-RC1:1.5 perseant-exfatfs-base-20250801:1.5 netbsd-11:1.5.0.10 netbsd-11-base:1.5 netbsd-10-1-RELEASE:1.5 perseant-exfatfs-base-20240630:1.5 perseant-exfatfs:1.5.0.8 perseant-exfatfs-base:1.5 netbsd-8-3-RELEASE:1.3.8.1 netbsd-9-4-RELEASE:1.3.18.1 netbsd-10-0-RELEASE:1.5 netbsd-10-0-RC6:1.5 netbsd-10-0-RC5:1.5 netbsd-10-0-RC4:1.5 bozohttpd-20240126:1.5 netbsd-10-0-RC3:1.5 netbsd-10-0-RC2:1.5 netbsd-10-0-RC1:1.5 netbsd-10:1.5.0.6 netbsd-10-base:1.5 netbsd-9-3-RELEASE:1.3.18.1 bozohttpd-20220517:1.5 cjep_sun2x-base1:1.5 cjep_sun2x:1.5.0.4 cjep_sun2x-base:1.5 cjep_staticlib_x-base1:1.5 netbsd-9-2-RELEASE:1.3.18.1 cjep_staticlib_x:1.5.0.2 cjep_staticlib_x-base:1.5 bozohttpd-20210227:1.4 netbsd-9-1-RELEASE:1.3 bozohttpd-20201014:1.4 bozohttpd-20200820:1.3 bozohttpd-20190228:1.3 phil-wifi-20200421:1.3 phil-wifi-20200411:1.3 is-mlppp:1.3.0.20 is-mlppp-base:1.3 phil-wifi-20200406:1.3 netbsd-8-2-RELEASE:1.3 netbsd-9-0-RELEASE:1.3 netbsd-9-0-RC2:1.3 netbsd-9-0-RC1:1.3 phil-wifi-20191119:1.3 netbsd-9:1.3.0.18 netbsd-9-base:1.3 phil-wifi-20190609:1.3 netbsd-8-1-RELEASE:1.3 netbsd-8-1-RC1:1.3 pgoyette-compat-merge-20190127:1.3 pgoyette-compat-20190127:1.3 pgoyette-compat-20190118:1.3 pgoyette-compat-1226:1.3 pgoyette-compat-1126:1.3 bozohttpd-20181125:1.3 bozohttpd-20181123:1.3 bozohttpd-20181121:1.3 bozohttpd-20181118:1.3 pgoyette-compat-1020:1.3 pgoyette-compat-0930:1.3 pgoyette-compat-0906:1.3 netbsd-7-2-RELEASE:1.2.18.1 pgoyette-compat-0728:1.3 netbsd-8-0-RELEASE:1.3 phil-wifi:1.3.0.16 phil-wifi-base:1.3 pgoyette-compat-0625:1.3 netbsd-8-0-RC2:1.3 pgoyette-compat-0521:1.3 pgoyette-compat-0502:1.3 pgoyette-compat-0422:1.3 netbsd-8-0-RC1:1.3 pgoyette-compat-0415:1.3 pgoyette-compat-0407:1.3 pgoyette-compat-0330:1.3 pgoyette-compat-0322:1.3 pgoyette-compat-0315:1.3 netbsd-7-1-2-RELEASE:1.2.18.1 pgoyette-compat:1.3.0.14 pgoyette-compat-base:1.3 netbsd-7-1-1-RELEASE:1.2.18.1 matt-nb8-mediatek:1.3.0.12 matt-nb8-mediatek-base:1.3 perseant-stdc-iso10646:1.3.0.10 perseant-stdc-iso10646-base:1.3 netbsd-8:1.3.0.8 netbsd-8-base:1.3 prg-localcount2-base3:1.3 prg-localcount2-base2:1.3 prg-localcount2-base1:1.3 prg-localcount2:1.3.0.6 prg-localcount2-base:1.3 pgoyette-localcount-20170426:1.3 bouyer-socketcan-base1:1.3 pgoyette-localcount-20170320:1.3 netbsd-7-1:1.2.18.1.0.4 netbsd-7-1-RELEASE:1.2.18.1 netbsd-7-1-RC2:1.2.18.1 netbsd-7-nhusb-base-20170116:1.2.18.1 bouyer-socketcan:1.3.0.4 bouyer-socketcan-base:1.3 pgoyette-localcount-20170107:1.3 netbsd-7-1-RC1:1.2.18.1 pgoyette-localcount-20161104:1.3 netbsd-7-0-2-RELEASE:1.2.22.1 localcount-20160914:1.3 netbsd-7-nhusb:1.2.18.1.0.2 netbsd-7-nhusb-base:1.2.18.1 pgoyette-localcount-20160806:1.3 pgoyette-localcount-20160726:1.3 pgoyette-localcount:1.3.0.2 pgoyette-localcount-base:1.3 netbsd-7-0-1-RELEASE:1.2.22.1 netbsd-7-0:1.2.0.22 netbsd-7-0-RELEASE:1.2 netbsd-7-0-RC3:1.2 netbsd-7-0-RC2:1.2 netbsd-7-0-RC1:1.2 bozohttpd-20150320:1.2 bozohttpd-20141225:1.2 netbsd-5-2-3-RELEASE:1.2.14.2 netbsd-5-1-5-RELEASE:1.2.16.2 netbsd-6-0-6-RELEASE:1.2.10.2 netbsd-6-1-5-RELEASE:1.2.8.2 tls-maxphys-base:1.2 tls-maxphys:1.2.0.20 netbsd-7:1.2.0.18 netbsd-7-base:1.2 netbsd-5-1:1.2.0.16 netbsd-5-2:1.2.0.14 netbsd-5:1.2.0.12 netbsd-6-0:1.2.0.10 netbsd-6-1:1.2.0.8 netbsd-6:1.2.0.6 yamt-pagecache:1.2.0.4 yamt-pagecache-base9:1.2 tls-earlyentropy:1.2.0.2 tls-earlyentropy-base:1.2 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.2 riastradh-drm2-base3:1.2 bozohttpd-20140102:1.2; locks; strict; comment @# @; 1.5 date 2021.02.28.16.10.00; author rillig; state Exp; branches; next 1.4; commitid u6kwA6p8CpW1JuJC; 1.4 date 2020.08.25.20.02.33; author leot; state Exp; branches; next 1.3; commitid 7742Z5TqRZHQ1ulC; 1.3 date 2015.12.07.03.11.48; author kamil; state Exp; branches 1.3.8.1 1.3.18.1; next 1.2; commitid TDWPNxU0iYW5MXLy; 1.2 date 2014.01.02.08.21.38; author mrg; state Exp; branches 1.2.4.1 1.2.6.1 1.2.8.1 1.2.10.1 1.2.12.1 1.2.14.1 1.2.16.1 1.2.18.1 1.2.20.1 1.2.22.1; next 1.1; commitid yV9n16GqKmvS9wjx; 1.1 date 2013.10.12.17.24.07; author mbalmer; state Exp; branches; next ; commitid LXlQXywxtlGIN19x; 1.3.8.1 date 2021.03.27.13.38.51; author martin; state Exp; branches; next ; commitid 0fy0WIi8VRCg1XMC; 1.3.18.1 date 2021.03.05.13.34.19; author martin; state Exp; branches; next ; commitid n1snW5vVPzYiG7KC; 1.2.4.1 date 2014.01.02.08.21.38; author yamt; state dead; branches; next 1.2.4.2; commitid VmckIax9CgOhKwBx; 1.2.4.2 date 2014.05.22.11.37.13; author yamt; state Exp; branches; next ; commitid VmckIax9CgOhKwBx; 1.2.6.1 date 2014.01.02.08.21.38; author msaitoh; state dead; branches; next 1.2.6.2; commitid PzA7yHFyE7G7zGHx; 1.2.6.2 date 2014.07.09.09.42.39; author msaitoh; state Exp; branches; next 1.2.6.3; commitid PzA7yHFyE7G7zGHx; 1.2.6.3 date 2016.04.15.19.36.08; author snj; state Exp; branches; next ; commitid oto82FwXp6Vs5L2z; 1.2.8.1 date 2014.01.02.08.21.38; author msaitoh; state dead; branches; next 1.2.8.2; commitid 5p14SLUnv4dRzGHx; 1.2.8.2 date 2014.07.09.09.44.56; author msaitoh; state Exp; branches; next 1.2.8.3; commitid 5p14SLUnv4dRzGHx; 1.2.8.3 date 2016.04.15.19.37.27; author snj; state Exp; branches; next ; commitid zYyoXbZSiqDU5L2z; 1.2.10.1 date 2014.01.02.08.21.38; author msaitoh; state dead; branches; next 1.2.10.2; commitid ncOq1490CSmnAGHx; 1.2.10.2 date 2014.07.09.09.47.11; author msaitoh; state Exp; branches; next 1.2.10.3; commitid ncOq1490CSmnAGHx; 1.2.10.3 date 2016.04.15.19.38.13; author snj; state Exp; branches; next ; commitid Uf1dmObit37d6L2z; 1.2.12.1 date 2014.01.02.08.21.38; author msaitoh; state dead; branches; next 1.2.12.2; commitid 6P3UulRicc5jrIHx; 1.2.12.2 date 2014.07.09.15.21.21; author msaitoh; state Exp; branches; next ; commitid 6P3UulRicc5jrIHx; 1.2.14.1 date 2014.01.02.08.21.38; author msaitoh; state dead; branches; next 1.2.14.2; commitid vGNE3klASBlIFIHx; 1.2.14.2 date 2014.07.09.16.04.13; author msaitoh; state Exp; branches; next ; commitid vGNE3klASBlIFIHx; 1.2.16.1 date 2014.01.02.08.21.38; author msaitoh; state dead; branches; next 1.2.16.2; commitid NgScSkUrfSmYHIHx; 1.2.16.2 date 2014.07.09.16.09.39; author msaitoh; state Exp; branches; next ; commitid NgScSkUrfSmYHIHx; 1.2.18.1 date 2016.04.10.10.33.11; author martin; state Exp; branches; next ; commitid bbLuZQFN3EQMe42z; 1.2.20.1 date 2014.01.02.08.21.38; author tls; state dead; branches; next 1.2.20.2; commitid jTnpym9Qu0o4R1Nx; 1.2.20.2 date 2014.08.20.00.02.22; author tls; state Exp; branches; next ; commitid jTnpym9Qu0o4R1Nx; 1.2.22.1 date 2016.04.15.18.55.49; author snj; state Exp; branches; next ; commitid RlNTxli26oeuRK2z; desc @@ 1.5 log @libexec/httpd: fix cross-site scripting in Lua example curl \ --header 'NAME: ' \ 'http://127.0.0.1:8080/test/printenv?=' @ text @-- $NetBSD: printenv.lua,v 1.4 2020/08/25 20:02:33 leot Exp $ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global variables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. -- You can test this example by running the following command: -- /usr/libexec/httpd -b -f -I 8080 -L test printenv.lua . -- and then navigate to: http://127.0.0.1:8080/test/printenv local httpd = require 'httpd' function escape_html(s) return s:gsub('&', '&'):gsub('<', '<'):gsub('>', '>'):gsub('"', '"') end function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program -- output headers using httpd.write() -- httpd.write() will not append newlines httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") -- output html using httpd.print() -- you can also use print() and io.write() but they will not work with SSL httpd.print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) httpd.print('module version: ' .. httpd._VERSION .. '
') httpd.print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') end httpd.print('

Request Headers

') for k, v in pairs(headers) do httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') end if query ~= nil then httpd.print('

Query Variables

') for k, v in pairs(query) do httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') end end httpd.print('

Form Test

') httpd.print([[
]]) -- output a footer httpd.print([[ ]]) end function form(env, header, query) httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") if query ~= nil then httpd.print('

Form Variables

') if env.CONTENT_TYPE ~= nil then httpd.print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') end else httpd.print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.4 log @Fix a typo in a comment @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.3 2015/12/07 03:11:48 kamil Exp $ d17 4 d47 1 a47 1 httpd.print(k .. '=' .. v .. '
') d52 1 a52 1 httpd.print(k .. '=' .. v .. '
') d58 1 a58 1 httpd.print(k .. '=' .. v .. '
') d90 1 a90 1 httpd.print(k .. '=' .. v .. '
') @ 1.3 log @Improve the httpd(8) printenv.lua Lua example Stop using Lua builtin print function and replace them with http.* ones. httpd.print and http.write wraps SSL support when needed. Print http headers, without them browser may interpret page as raw text. No need to hardcode prefix path in the form. Add comments for a user with tips how to use this script. Patch by Travis Paul Closes PR misc/50502 @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.2 2014/01/02 08:21:38 mrg Exp $ d7 1 a7 1 -- daemon mode, you can set global veriables here, but they will have @ 1.3.8.1 log @Pull up the following via patch, requested by mrg in ticket #1668: Makefile 1.30-1.31 Makefile.boot 1.7-1.9 auth-bozo.c 1.25-1.26 bozohttpd.8 1.80-1.87 bozohttpd.c 1.114-1.123,1.125-1.128 bozohttpd.h 1.61-1.68 cgi-bozo.c 1.49-1.53 content-bozo.c 1.17-1.20 daemon-bozo.c 1-.22 dir-index-bozo.c 1.33-1.34 main.c 1.23-1.27 printenv.lua 1.4-1.5 ssl-bozo.c 1.27-1.29 libbozohttpd/libbozohttpd.3 1.5-1.6 small/Makefile 1.4 testsuite/Makefile 1.14 testsuite/t16.in 1.1 testsuite/t16.out 1.1 testsuite/t17.in 1.1 testsuite/t17.out 1.1 testsuite/t18.in 1.1 testsuite/t18.out 1.1 Update to bozohttpd 20210227. changes in bozohttpd 20210227: o new support for content types: .tar.bz2, .tar.xz, .tar.lz, .tar.zst, .tbz2, .txz, .tlz, .zipx, .xz, .zst, .sz, .lz, .lzma, .lzo, .7z, .lzo, .cab, .dmg, .jar, and .rar. should fix netbsd PR#56026: MIME type of .tar.xz file on ny{cdn,ftp}.NetBSD.org is invalid changes in bozohttpd 20210211: o fix various NULL derefs from malformed headers. mostly from . o fix memory leaks in library interface: add bozo_cleanup(). changes in bozohttpd 20201014: o also set -D_GNU_SOURCE in Makefile.boot. from hadrien.lacour@@posteo.net. o fix array size botch (assertion, not exploitable.) from martin@@netbsd.org. o also match %2F as well as %2f. from leah@@vuxu.org. o many manual and help fixes. clean ups for higher lint levels, consistency/style clean ups. various option fixes including made -f imply -b. from for freebsd. changes in bozohttpd 20200912: o add .m4a and .m4v file extensions. changes in bozohttpd 20200820: o make this work on sun2 by reducing mmap window there. o fix SSL shutdown sequence. from spz@@netbsd.org. o add readme support to directory indexing. from jmcneill@@netbsd.org o add blocklist(8) support. from jruoho@@netbsd.org. @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.3 2015/12/07 03:11:48 kamil Exp $ d7 1 a7 1 -- daemon mode, you can set global variables here, but they will have a16 4 function escape_html(s) return s:gsub('&', '&'):gsub('<', '<'):gsub('>', '>'):gsub('"', '"') end d43 1 a43 1 httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') d48 1 a48 1 httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') d54 1 a54 1 httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') d86 1 a86 1 httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') @ 1.3.18.1 log @Pull up the following (all via patch), requested by mrg in ticket #1221: lib/lua/bozohttpd/Makefile (apply patch) libexec/httpd/Makefile 1.30-1.31 libexec/httpd/Makefile.boot 1.7-1.9 libexec/httpd/auth-bozo.c 1.25-1.26 libexec/httpd/bozohttpd.8 1.80-1.87 libexec/httpd/bozohttpd.c 1.114-1.123,1.125-1.128 libexec/httpd/bozohttpd.h 1.61-1.68 libexec/httpd/cgi-bozo.c 1.49-1.53 libexec/httpd/content-bozo.c 1.17-1.20 libexec/httpd/daemon-bozo.c 1-.22 libexec/httpd/dir-index-bozo.c 1.33-1.34 libexec/httpd/main.c 1.23-1.27 libexec/httpd/printenv.lua 1.4-1.5 libexec/httpd/ssl-bozo.c 1.27-1.29 libexec/httpd/libbozohttpd/libbozohttpd.3 1.5-1.6 libexec/httpd/small/Makefile 1.4 libexec/httpd/testsuite/Makefile 1.14 libexec/httpd/testsuite/t16.in 1.1 libexec/httpd/testsuite/t16.out 1.1 libexec/httpd/testsuite/t17.in 1.1 libexec/httpd/testsuite/t17.out 1.1 libexec/httpd/testsuite/t18.in 1.1 libexec/httpd/testsuite/t18.out 1.1 Update to bozohttpd 20210227. Apply lua build fix (no blocklist support on this branch). changes in bozohttpd 20210227: o new support for content types: .tar.bz2, .tar.xz, .tar.lz, .tar.zst, .tbz2, .txz, .tlz, .zipx, .xz, .zst, .sz, .lz, .lzma, .lzo, .7z, .lzo, .cab, .dmg, .jar, and .rar. should fix netbsd PR#56026: MIME type of .tar.xz file on ny{cdn,ftp}.NetBSD.org is invalid changes in bozohttpd 20210211: o fix various NULL derefs from malformed headers. mostly from . o fix memory leaks in library interface: add bozo_cleanup(). changes in bozohttpd 20201014: o also set -D_GNU_SOURCE in Makefile.boot. from hadrien.lacour@@posteo.net. o fix array size botch (assertion, not exploitable.) from martin@@netbsd.org. o also match %2F as well as %2f. from leah@@vuxu.org. o many manual and help fixes. clean ups for higher lint levels, consistency/style clean ups. various option fixes including made -f imply -b. from for freebsd. changes in bozohttpd 20200912: o add .m4a and .m4v file extensions. changes in bozohttpd 20200820: o make this work on sun2 by reducing mmap window there. o fix SSL shutdown sequence. from spz@@netbsd.org. o add readme support to directory indexing. from jmcneill@@netbsd.org o add blocklist(8) support. from jruoho@@netbsd.org. @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.3 2015/12/07 03:11:48 kamil Exp $ d7 1 a7 1 -- daemon mode, you can set global variables here, but they will have a16 4 function escape_html(s) return s:gsub('&', '&'):gsub('<', '<'):gsub('>', '>'):gsub('"', '"') end d43 1 a43 1 httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') d48 1 a48 1 httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') d54 1 a54 1 httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') d86 1 a86 1 httpd.print(escape_html(k) .. '=' .. escape_html(v) .. '
') @ 1.2 log @- update CHANGES with recent changes - update version to 20140102 - update copyrights - use getcwd() over getwd() - fix lean build (don't include lua) @ text @d1 1 a1 1 -- $NetBSD$ d11 4 d22 8 a29 6 if count == nil then count = 1 end -- output a header print([[ d38 1 a38 1 print('module version: ' .. httpd._VERSION .. '
') d40 1 a40 1 print('

Server Environment

') d43 1 a43 1 print(k .. '=' .. v .. '
') d46 1 a46 1 print('

Request Headers

') d48 1 a48 1 print(k .. '=' .. v .. '
') d52 1 a52 1 print('

Query Variables

') d54 1 a54 1 print(k .. '=' .. v .. '
') d58 1 a58 1 print('

Form Test

') d60 2 a61 2 print([[
d67 1 a67 1 print([[ d74 4 d79 1 a79 1 print('

Form Variables

') d82 1 a82 1 print('Content-type: ' .. env.CONTENT_TYPE .. '
') d86 1 a86 1 print(k .. '=' .. v .. '
') d89 1 a89 1 print('No values') @ 1.2.22.1 log @Pull up following revision(s) (requested by mrg in ticket #1141): libexec/httpd/CHANGES: up to 1.22 libexec/httpd/Makefile: up to 1.26 libexec/httpd/auth-bozo.c: up to 1.18 libexec/httpd/bozohttpd.8: up to 1.59 libexec/httpd/bozohttpd.c: up to 1.80 libexec/httpd/bozohttpd.h: up to 1.45 libexec/httpd/cgi-bozo.c: up to 1.33 libexec/httpd/content-bozo.c: up to 1.13 libexec/httpd/daemon-bozo.c: up to 1.17 libexec/httpd/dir-index-bozo.c: up to 1.25 libexec/httpd/lua-bozo.c: up to 1.14 libexec/httpd/lua/bozo.lua: up to 1.2 libexec/httpd/lua/glue.c: up to 1.2 libexec/httpd/main.c: up to 1.13 libexec/httpd/printenv.lua: up to 1.3 libexec/httpd/ssl-bozo.c: up to 1.22 libexec/httpd/testsuite/Makefile: up to 1.5 libexec/httpd/testsuite/test-bigfile: up to 1.2 libexec/httpd/tilde-luzah-bozo.c: up to 1.14 Import bozohttpd 20151028: o add CGI support for ~user translation (-E switch) o add redirects to ~user translation o fix bugs around ~user translation o add schema detection for absolute redirects o fixed few memory leaks o bunch of minor tweaks o removed -r support o smarter redirects Changes in 20150320: o fix redirection handling o support transport stream (.ts) and video object (.vob) files o directory listings show correct file sizes for large files -- updates and bozohttpd 20160415: o add search-word support for CGI o fix a security issue in CGI suffix handler support which would allow remote code execution, from shm@@netbsd.org o -C option supports now CGI scripts only @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.3 2015/12/07 03:11:48 kamil Exp $ a10 4 -- You can test this example by running the following command: -- /usr/libexec/httpd -b -f -I 8080 -L test printenv.lua . -- and then navigate to: http://127.0.0.1:8080/test/printenv d18 6 a23 8 -- output headers using httpd.write() -- httpd.write() will not append newlines httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") -- output html using httpd.print() -- you can also use print() and io.write() but they will not work with SSL httpd.print([[ d32 1 a32 1 httpd.print('module version: ' .. httpd._VERSION .. '
') d34 1 a34 1 httpd.print('

Server Environment

') d37 1 a37 1 httpd.print(k .. '=' .. v .. '
') d40 1 a40 1 httpd.print('

Request Headers

') d42 1 a42 1 httpd.print(k .. '=' .. v .. '
') d46 1 a46 1 httpd.print('

Query Variables

') d48 1 a48 1 httpd.print(k .. '=' .. v .. '
') d52 1 a52 1 httpd.print('

Form Test

') d54 2 a55 2 httpd.print([[ d61 1 a61 1 httpd.print([[ a67 4 httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") d69 1 a69 1 httpd.print('

Form Variables

') d72 1 a72 1 httpd.print('Content-type: ' .. env.CONTENT_TYPE .. '
') d76 1 a76 1 httpd.print(k .. '=' .. v .. '
') d79 1 a79 1 httpd.print('No values') @ 1.2.18.1 log @Catch up to -current (via patch), requested by mspo in #1141: libexec/httpd/CHANGES up to 1.21 libexec/httpd/Makefile up to 1.26 libexec/httpd/auth-bozo.c up to 1.18 libexec/httpd/bozohttpd.8 up to 1.58 libexec/httpd/bozohttpd.c up to 1.79 libexec/httpd/bozohttpd.h up to 1.44 libexec/httpd/cgi-bozo.c up to 1.32 libexec/httpd/content-bozo.c up to 1.13 libexec/httpd/daemon-bozo.c up to 1.17 libexec/httpd/dir-index-bozo.c up to 1.25 libexec/httpd/lua-bozo.c up to 1.14 libexec/httpd/main.c up to 1.13 libexec/httpd/netbsd_queue.h up to 1.1 libexec/httpd/printenv.lua up to 1.3 libexec/httpd/ssl-bozo.c up to 1.22 libexec/httpd/tilde-luzah-bozo.c up to 1.14 libexec/httpd/testsuite/Makefile up to 1.5 libexec/httpd/testsuite/test-bigfile up to 1.2 Import bozohttpd 20151028: o add CGI support for ~user translation (-E switch) o add redirects to ~user translation o fix bugs around ~user translation o add schema detection for absolute redirects o fixed few memory leaks o bunch of minor tweaks o removed -r support o smarter redirects Changes in 20150320: o fix redirection handling o support transport stream (.ts) and video object (.vob) files o directory listings show correct file sizes for large files @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.2 2014/01/02 08:21:38 mrg Exp $ a10 4 -- You can test this example by running the following command: -- /usr/libexec/httpd -b -f -I 8080 -L test printenv.lua . -- and then navigate to: http://127.0.0.1:8080/test/printenv d18 6 a23 8 -- output headers using httpd.write() -- httpd.write() will not append newlines httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") -- output html using httpd.print() -- you can also use print() and io.write() but they will not work with SSL httpd.print([[ d32 1 a32 1 httpd.print('module version: ' .. httpd._VERSION .. '
') d34 1 a34 1 httpd.print('

Server Environment

') d37 1 a37 1 httpd.print(k .. '=' .. v .. '
') d40 1 a40 1 httpd.print('

Request Headers

') d42 1 a42 1 httpd.print(k .. '=' .. v .. '
') d46 1 a46 1 httpd.print('

Query Variables

') d48 1 a48 1 httpd.print(k .. '=' .. v .. '
') d52 1 a52 1 httpd.print('

Form Test

') d54 2 a55 2 httpd.print([[ d61 1 a61 1 httpd.print([[ a67 4 httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") d69 1 a69 1 httpd.print('

Form Variables

') d72 1 a72 1 httpd.print('Content-type: ' .. env.CONTENT_TYPE .. '
') d76 1 a76 1 httpd.print(k .. '=' .. v .. '
') d79 1 a79 1 httpd.print('No values') @ 1.2.20.1 log @file printenv.lua was added on branch tls-maxphys on 2014-08-20 00:02:22 +0000 @ text @d1 85 @ 1.2.20.2 log @Rebase to HEAD as of a few days ago. @ text @a0 85 -- $NetBSD$ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global veriables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. local httpd = require 'httpd' function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program if count == nil then count = 1 end -- output a header print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) print('module version: ' .. httpd._VERSION .. '
') print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do print(k .. '=' .. v .. '
') end print('

Request Headers

') for k, v in pairs(headers) do print(k .. '=' .. v .. '
') end if query ~= nil then print('

Query Variables

') for k, v in pairs(query) do print(k .. '=' .. v .. '
') end end print('

Form Test

') print([[
]]) -- output a footer print([[ ]]) end function form(env, header, query) if query ~= nil then print('

Form Variables

') if env.CONTENT_TYPE ~= nil then print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do print(k .. '=' .. v .. '
') end else print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.2.16.1 log @file printenv.lua was added on branch netbsd-5-1 on 2014-07-09 16:09:39 +0000 @ text @d1 85 @ 1.2.16.2 log @Pull up following revision(s) (requested by mrg in ticket #1913): libexec/httpd/CHANGES 1.3-1.18 libexec/httpd/Makefile 1.8-1.22 via patch libexec/httpd/Makefile.boot 1.3-1.6 libexec/httpd/auth-bozo.c 1.5-1.13 libexec/httpd/bozohttpd.8 1.6-1.46 libexec/httpd/bozohttpd.c 1.8,1.12-1.54 libexec/httpd/bozohttpd.h 1.8-1.32 libexec/httpd/cgi-bozo.c 1.11-1.25 libexec/httpd/content-bozo.c 1.4-1.10 libexec/httpd/daemon-bozo.c 1.5-1.16 libexec/httpd/dir-index-bozo.c 1.6-1.19 libexec/httpd/ssl-bozo.c 1.5-1.16 libexec/httpd/tilde-luzah-bozo.c 1.5-1.10 libexec/httpd/lua-bozo.c 1.1-1.9 libexec/httpd/main.c 1.1-1.7 libexec/httpd/netbsd_queue.h 1.1 libexec/httpd/printenv.lua 1.1-1.2 libexec/httpd/debug/Makefile 1.1 libexec/httpd/libbozohttpd/Makefile 1.2 libexec/httpd/libbozohttpd/libbozohttpd.3 1.3 libexec/httpd/libbozohttpd/shlib_version 1.1 libexec/httpd/lua/Makefile 1.1 libexec/httpd/lua/bozo.lua 1.1 libexec/httpd/lua/glue.c 1.1 libexec/httpd/lua/optparse.lua 1.1 libexec/httpd/lua/shlib_version 1.1 libexec/httpd/small/Makefile 1.1-1.2 libexec/httpd/testsuite/Makefile 1.4 libexec/httpd/testsuite/html_cmp 1.4 libexec/httpd/testsuite/t1.in 1.3 libexec/httpd/testsuite/t1.out 1.3 libexec/httpd/testsuite/t10.in 1.1 libexec/httpd/testsuite/t10.out 1.1 libexec/httpd/testsuite/t2.in 1.3 libexec/httpd/testsuite/t2.out 1.3 libexec/httpd/testsuite/t3.in 1.3 libexec/httpd/testsuite/t3.out 1.3 libexec/httpd/testsuite/t4.in 1.3 libexec/httpd/testsuite/t4.out 1.3 libexec/httpd/testsuite/t5.in 1.3 libexec/httpd/testsuite/t5.out 1.3 libexec/httpd/testsuite/t6.in 1.3 libexec/httpd/testsuite/t6.out 1.3 libexec/httpd/testsuite/t7.in 1.3 libexec/httpd/testsuite/t7.out 1.3 libexec/httpd/testsuite/t8.in 1.3 libexec/httpd/testsuite/t8.out 1.3 libexec/httpd/testsuite/t9.in 1.3 libexec/httpd/testsuite/t9.out 1.3 libexec/httpd/testsuite/test-bigfile 1.1 libexec/httpd/testsuite/data/bigfile 1.1 libexec/httpd/testsuite/data/bigfile.partial4000 1.1 libexec/httpd/testsuite/data/bigfile.partial8000 1.1 libexec/httpd/testsuite/data/file 1.3 libexec/httpd/testsuite/data/index.html 1.3 Update bozohttpd from 20080303+patches to 20140708. changes in bozohttpd 20140708: o fixes for virtual host support, from rajeev_v_pillai@@yahoo.com o avoid printing double errors, from shm@@netbsd.org o fix a security issue in basic HTTP authentication which would allow authentication to be bypassed, from shm@@netbsd.org changes in bozohttpd 20140201: o support .svg files o fix a core dump when requests timeout changes in bozohttpd 20140102: o update a few content types o add support for directly calling lua scripts to handle processes, from mbalmer@@netbsd.org o properly escape generated HTML o add authentication for redirections, from martin@@netbsd.org o handle chained ssl certifications, from elric@@netbsd.org o add basic support for gzipped files, from elric@@netbsd.org o properly escape generated URIs changes in bozohttpd 20111118: o add -P option, from jmmv@@netbsd.org o avoid crashes with http basic auth, from pooka@@netbsd.org o add support for REDIRECT_STATUS variable, from tls@@netbsd.org o support .mp4 files in the default map o directory indexes with files with : are now displayed properly, from reed@@netbsd.org o allow -I option to be useful in non-inetd mode as well changes in bozohttpd 20100920: o properly fully disable multi-file mode for now o fix the -t and -U options when used without the -e option, broken since the library-ifcation o be explicit that logs go to the FTP facility in syslog o use scandir() with alphasort() for sorted directory lists, from moof o fix a serious error in vhost handling; "Host:.." would allow access to the next level directory from the virtual root directory, from seanb o fix some various non standard compile time errors, from rudolf o fix dynamic CGI content maps, from rudolf changes in bozohttpd 20100617: o fix some compile issues o fix SSL mode. from rtr o fix some cgi-bin issues, as seen with cvsweb o disable multi-file daemon mode for now, it breaks o return 404's instead of 403's when chdir of ~user dirs fail o remove "noreturn" attribute from bozo_http_error() that was causing incorrect runtime behaviour changes in bozohttpd 20100509: o major rework and clean up of internal interfaces. move the main program into main.c, the remaining parts are useable as library. add bindings for lua. by Alistair G. Crooks o fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=566325 changes in bozohttpd 20090522: o avoid dying in daemon mode for some uncommon, but recoverable, errors o close leaking file descriptors for CGI and daemon mode o handle poll errors properly o don't try to handle more than one request per process yet o add subdirs for build "debug" and "small" versions o clean up a bad merge / duplicate code o make mmap() usage portable, fixes linux & ranges: support o document the -f option o daemon mode now serves 6 files per child changes in bozohttpd 20090417: o make bozohttpd internally more modular, preparing the way to handle more than one request per process o fix http-auth, set $REMOTE_USER not $REMOTEUSER. also fix cgi-bin with cvsweb, from Holger Weiss o fix an uninitialised variable use in daemon mode o fix ssl mode with newer OpenSSL o mmap large files in manageable sizes so we can serve any size file o refactor url processing to handle query strings correctly for CGI from Sergey Katsev at Coyote Point o add If-Modified-Since support, from Joerg Sonnenberger o many more manual fixes, from NetBSD @ text @a0 85 -- $NetBSD: printenv.lua,v 1.2 2014/01/02 08:21:38 mrg Exp $ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global veriables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. local httpd = require 'httpd' function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program if count == nil then count = 1 end -- output a header print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) print('module version: ' .. httpd._VERSION .. '
') print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do print(k .. '=' .. v .. '
') end print('

Request Headers

') for k, v in pairs(headers) do print(k .. '=' .. v .. '
') end if query ~= nil then print('

Query Variables

') for k, v in pairs(query) do print(k .. '=' .. v .. '
') end end print('

Form Test

') print([[
]]) -- output a footer print([[ ]]) end function form(env, header, query) if query ~= nil then print('

Form Variables

') if env.CONTENT_TYPE ~= nil then print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do print(k .. '=' .. v .. '
') end else print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.2.14.1 log @file printenv.lua was added on branch netbsd-5-2 on 2014-07-09 16:04:13 +0000 @ text @d1 85 @ 1.2.14.2 log @Pull up following revision(s) (requested by mrg in ticket #1913): libexec/httpd/CHANGES 1.3-1.18 libexec/httpd/Makefile 1.8-1.22 via patch libexec/httpd/Makefile.boot 1.3-1.6 libexec/httpd/auth-bozo.c 1.5-1.13 libexec/httpd/bozohttpd.8 1.6-1.46 libexec/httpd/bozohttpd.c 1.8,1.12-1.54 libexec/httpd/bozohttpd.h 1.8-1.32 libexec/httpd/cgi-bozo.c 1.11-1.25 libexec/httpd/content-bozo.c 1.4-1.10 libexec/httpd/daemon-bozo.c 1.5-1.16 libexec/httpd/dir-index-bozo.c 1.6-1.19 libexec/httpd/ssl-bozo.c 1.5-1.16 libexec/httpd/tilde-luzah-bozo.c 1.5-1.10 libexec/httpd/lua-bozo.c 1.1-1.9 libexec/httpd/main.c 1.1-1.7 libexec/httpd/netbsd_queue.h 1.1 libexec/httpd/printenv.lua 1.1-1.2 libexec/httpd/debug/Makefile 1.1 libexec/httpd/libbozohttpd/Makefile 1.2 libexec/httpd/libbozohttpd/libbozohttpd.3 1.3 libexec/httpd/libbozohttpd/shlib_version 1.1 libexec/httpd/lua/Makefile 1.1 libexec/httpd/lua/bozo.lua 1.1 libexec/httpd/lua/glue.c 1.1 libexec/httpd/lua/optparse.lua 1.1 libexec/httpd/lua/shlib_version 1.1 libexec/httpd/small/Makefile 1.1-1.2 libexec/httpd/testsuite/Makefile 1.4 libexec/httpd/testsuite/html_cmp 1.4 libexec/httpd/testsuite/t1.in 1.3 libexec/httpd/testsuite/t1.out 1.3 libexec/httpd/testsuite/t10.in 1.1 libexec/httpd/testsuite/t10.out 1.1 libexec/httpd/testsuite/t2.in 1.3 libexec/httpd/testsuite/t2.out 1.3 libexec/httpd/testsuite/t3.in 1.3 libexec/httpd/testsuite/t3.out 1.3 libexec/httpd/testsuite/t4.in 1.3 libexec/httpd/testsuite/t4.out 1.3 libexec/httpd/testsuite/t5.in 1.3 libexec/httpd/testsuite/t5.out 1.3 libexec/httpd/testsuite/t6.in 1.3 libexec/httpd/testsuite/t6.out 1.3 libexec/httpd/testsuite/t7.in 1.3 libexec/httpd/testsuite/t7.out 1.3 libexec/httpd/testsuite/t8.in 1.3 libexec/httpd/testsuite/t8.out 1.3 libexec/httpd/testsuite/t9.in 1.3 libexec/httpd/testsuite/t9.out 1.3 libexec/httpd/testsuite/test-bigfile 1.1 libexec/httpd/testsuite/data/bigfile 1.1 libexec/httpd/testsuite/data/bigfile.partial4000 1.1 libexec/httpd/testsuite/data/bigfile.partial8000 1.1 libexec/httpd/testsuite/data/file 1.3 libexec/httpd/testsuite/data/index.html 1.3 Update bozohttpd from 20080303+patches to 20140708. changes in bozohttpd 20140708: o fixes for virtual host support, from rajeev_v_pillai@@yahoo.com o avoid printing double errors, from shm@@netbsd.org o fix a security issue in basic HTTP authentication which would allow authentication to be bypassed, from shm@@netbsd.org changes in bozohttpd 20140201: o support .svg files o fix a core dump when requests timeout changes in bozohttpd 20140102: o update a few content types o add support for directly calling lua scripts to handle processes, from mbalmer@@netbsd.org o properly escape generated HTML o add authentication for redirections, from martin@@netbsd.org o handle chained ssl certifications, from elric@@netbsd.org o add basic support for gzipped files, from elric@@netbsd.org o properly escape generated URIs changes in bozohttpd 20111118: o add -P option, from jmmv@@netbsd.org o avoid crashes with http basic auth, from pooka@@netbsd.org o add support for REDIRECT_STATUS variable, from tls@@netbsd.org o support .mp4 files in the default map o directory indexes with files with : are now displayed properly, from reed@@netbsd.org o allow -I option to be useful in non-inetd mode as well changes in bozohttpd 20100920: o properly fully disable multi-file mode for now o fix the -t and -U options when used without the -e option, broken since the library-ifcation o be explicit that logs go to the FTP facility in syslog o use scandir() with alphasort() for sorted directory lists, from moof o fix a serious error in vhost handling; "Host:.." would allow access to the next level directory from the virtual root directory, from seanb o fix some various non standard compile time errors, from rudolf o fix dynamic CGI content maps, from rudolf changes in bozohttpd 20100617: o fix some compile issues o fix SSL mode. from rtr o fix some cgi-bin issues, as seen with cvsweb o disable multi-file daemon mode for now, it breaks o return 404's instead of 403's when chdir of ~user dirs fail o remove "noreturn" attribute from bozo_http_error() that was causing incorrect runtime behaviour changes in bozohttpd 20100509: o major rework and clean up of internal interfaces. move the main program into main.c, the remaining parts are useable as library. add bindings for lua. by Alistair G. Crooks o fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=566325 changes in bozohttpd 20090522: o avoid dying in daemon mode for some uncommon, but recoverable, errors o close leaking file descriptors for CGI and daemon mode o handle poll errors properly o don't try to handle more than one request per process yet o add subdirs for build "debug" and "small" versions o clean up a bad merge / duplicate code o make mmap() usage portable, fixes linux & ranges: support o document the -f option o daemon mode now serves 6 files per child changes in bozohttpd 20090417: o make bozohttpd internally more modular, preparing the way to handle more than one request per process o fix http-auth, set $REMOTE_USER not $REMOTEUSER. also fix cgi-bin with cvsweb, from Holger Weiss o fix an uninitialised variable use in daemon mode o fix ssl mode with newer OpenSSL o mmap large files in manageable sizes so we can serve any size file o refactor url processing to handle query strings correctly for CGI from Sergey Katsev at Coyote Point o add If-Modified-Since support, from Joerg Sonnenberger o many more manual fixes, from NetBSD @ text @a0 85 -- $NetBSD: printenv.lua,v 1.2 2014/01/02 08:21:38 mrg Exp $ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global veriables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. local httpd = require 'httpd' function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program if count == nil then count = 1 end -- output a header print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) print('module version: ' .. httpd._VERSION .. '
') print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do print(k .. '=' .. v .. '
') end print('

Request Headers

') for k, v in pairs(headers) do print(k .. '=' .. v .. '
') end if query ~= nil then print('

Query Variables

') for k, v in pairs(query) do print(k .. '=' .. v .. '
') end end print('

Form Test

') print([[
]]) -- output a footer print([[ ]]) end function form(env, header, query) if query ~= nil then print('

Form Variables

') if env.CONTENT_TYPE ~= nil then print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do print(k .. '=' .. v .. '
') end else print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.2.12.1 log @file printenv.lua was added on branch netbsd-5 on 2014-07-09 15:21:21 +0000 @ text @d1 85 @ 1.2.12.2 log @Pull up following revision(s) (requested by mrg in ticket #1913): libexec/httpd/CHANGES 1.3-1.18 libexec/httpd/Makefile 1.8-1.22 via patch libexec/httpd/Makefile.boot 1.3-1.6 libexec/httpd/auth-bozo.c 1.5-1.13 libexec/httpd/bozohttpd.8 1.6-1.46 libexec/httpd/bozohttpd.c 1.8,1.12-1.54 libexec/httpd/bozohttpd.h 1.8-1.32 libexec/httpd/cgi-bozo.c 1.11-1.25 libexec/httpd/content-bozo.c 1.4-1.10 libexec/httpd/daemon-bozo.c 1.5-1.16 libexec/httpd/dir-index-bozo.c 1.6-1.19 libexec/httpd/ssl-bozo.c 1.5-1.16 libexec/httpd/tilde-luzah-bozo.c 1.5-1.10 libexec/httpd/lua-bozo.c 1.1-1.9 libexec/httpd/main.c 1.1-1.7 libexec/httpd/netbsd_queue.h 1.1 libexec/httpd/printenv.lua 1.1-1.2 libexec/httpd/debug/Makefile 1.1 libexec/httpd/libbozohttpd/Makefile 1.2 libexec/httpd/libbozohttpd/libbozohttpd.3 1.3 libexec/httpd/libbozohttpd/shlib_version 1.1 libexec/httpd/lua/Makefile 1.1 libexec/httpd/lua/bozo.lua 1.1 libexec/httpd/lua/glue.c 1.1 libexec/httpd/lua/optparse.lua 1.1 libexec/httpd/lua/shlib_version 1.1 libexec/httpd/small/Makefile 1.1-1.2 libexec/httpd/testsuite/Makefile 1.4 libexec/httpd/testsuite/html_cmp 1.4 libexec/httpd/testsuite/t1.in 1.3 libexec/httpd/testsuite/t1.out 1.3 libexec/httpd/testsuite/t10.in 1.1 libexec/httpd/testsuite/t10.out 1.1 libexec/httpd/testsuite/t2.in 1.3 libexec/httpd/testsuite/t2.out 1.3 libexec/httpd/testsuite/t3.in 1.3 libexec/httpd/testsuite/t3.out 1.3 libexec/httpd/testsuite/t4.in 1.3 libexec/httpd/testsuite/t4.out 1.3 libexec/httpd/testsuite/t5.in 1.3 libexec/httpd/testsuite/t5.out 1.3 libexec/httpd/testsuite/t6.in 1.3 libexec/httpd/testsuite/t6.out 1.3 libexec/httpd/testsuite/t7.in 1.3 libexec/httpd/testsuite/t7.out 1.3 libexec/httpd/testsuite/t8.in 1.3 libexec/httpd/testsuite/t8.out 1.3 libexec/httpd/testsuite/t9.in 1.3 libexec/httpd/testsuite/t9.out 1.3 libexec/httpd/testsuite/test-bigfile 1.1 libexec/httpd/testsuite/data/bigfile 1.1 libexec/httpd/testsuite/data/bigfile.partial4000 1.1 libexec/httpd/testsuite/data/bigfile.partial8000 1.1 libexec/httpd/testsuite/data/file 1.3 libexec/httpd/testsuite/data/index.html 1.3 Update bozohttpd from 20080303+patches to 20140708. changes in bozohttpd 20140708: o fixes for virtual host support, from rajeev_v_pillai@@yahoo.com o avoid printing double errors, from shm@@netbsd.org o fix a security issue in basic HTTP authentication which would allow authentication to be bypassed, from shm@@netbsd.org changes in bozohttpd 20140201: o support .svg files o fix a core dump when requests timeout changes in bozohttpd 20140102: o update a few content types o add support for directly calling lua scripts to handle processes, from mbalmer@@netbsd.org o properly escape generated HTML o add authentication for redirections, from martin@@netbsd.org o handle chained ssl certifications, from elric@@netbsd.org o add basic support for gzipped files, from elric@@netbsd.org o properly escape generated URIs changes in bozohttpd 20111118: o add -P option, from jmmv@@netbsd.org o avoid crashes with http basic auth, from pooka@@netbsd.org o add support for REDIRECT_STATUS variable, from tls@@netbsd.org o support .mp4 files in the default map o directory indexes with files with : are now displayed properly, from reed@@netbsd.org o allow -I option to be useful in non-inetd mode as well changes in bozohttpd 20100920: o properly fully disable multi-file mode for now o fix the -t and -U options when used without the -e option, broken since the library-ifcation o be explicit that logs go to the FTP facility in syslog o use scandir() with alphasort() for sorted directory lists, from moof o fix a serious error in vhost handling; "Host:.." would allow access to the next level directory from the virtual root directory, from seanb o fix some various non standard compile time errors, from rudolf o fix dynamic CGI content maps, from rudolf changes in bozohttpd 20100617: o fix some compile issues o fix SSL mode. from rtr o fix some cgi-bin issues, as seen with cvsweb o disable multi-file daemon mode for now, it breaks o return 404's instead of 403's when chdir of ~user dirs fail o remove "noreturn" attribute from bozo_http_error() that was causing incorrect runtime behaviour changes in bozohttpd 20100509: o major rework and clean up of internal interfaces. move the main program into main.c, the remaining parts are useable as library. add bindings for lua. by Alistair G. Crooks o fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=566325 changes in bozohttpd 20090522: o avoid dying in daemon mode for some uncommon, but recoverable, errors o close leaking file descriptors for CGI and daemon mode o handle poll errors properly o don't try to handle more than one request per process yet o add subdirs for build "debug" and "small" versions o clean up a bad merge / duplicate code o make mmap() usage portable, fixes linux & ranges: support o document the -f option o daemon mode now serves 6 files per child changes in bozohttpd 20090417: o make bozohttpd internally more modular, preparing the way to handle more than one request per process o fix http-auth, set $REMOTE_USER not $REMOTEUSER. also fix cgi-bin with cvsweb, from Holger Weiss o fix an uninitialised variable use in daemon mode o fix ssl mode with newer OpenSSL o mmap large files in manageable sizes so we can serve any size file o refactor url processing to handle query strings correctly for CGI from Sergey Katsev at Coyote Point o add If-Modified-Since support, from Joerg Sonnenberger o many more manual fixes, from NetBSD @ text @a0 85 -- $NetBSD: printenv.lua,v 1.2 2014/01/02 08:21:38 mrg Exp $ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global veriables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. local httpd = require 'httpd' function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program if count == nil then count = 1 end -- output a header print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) print('module version: ' .. httpd._VERSION .. '
') print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do print(k .. '=' .. v .. '
') end print('

Request Headers

') for k, v in pairs(headers) do print(k .. '=' .. v .. '
') end if query ~= nil then print('

Query Variables

') for k, v in pairs(query) do print(k .. '=' .. v .. '
') end end print('

Form Test

') print([[
]]) -- output a footer print([[ ]]) end function form(env, header, query) if query ~= nil then print('

Form Variables

') if env.CONTENT_TYPE ~= nil then print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do print(k .. '=' .. v .. '
') end else print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.2.10.1 log @file printenv.lua was added on branch netbsd-6-0 on 2014-07-09 09:47:11 +0000 @ text @d1 85 @ 1.2.10.2 log @Pull up following revision(s) (requested by mrg in ticket #1095): libexec/httpd/CHANGES 1.12-1.18 libexec/httpd/Makefile 1.13-1.22 libexec/httpd/Makefile.boot 1.6 libexec/httpd/auth-bozo.c 1.11-1.13 libexec/httpd/bozohttpd.8 1.33-1.46 libexec/httpd/bozohttpd.c 1.31-1.54 libexec/httpd/bozohttpd.h 1.21-1.32 libexec/httpd/cgi-bozo.c 1.21-1.25 libexec/httpd/content-bozo.c 1.8-1.10 libexec/httpd/daemon-bozo.c 1.16-1.16 libexec/httpd/dir-index-bozo.c 1.15-1.19 libexec/httpd/lua-bozo.c 1.1-1.9 libexec/httpd/main.c 1.6-1.7 libexec/httpd/netbsd_queue.h 1.1 libexec/httpd/printenv.lua 1.1-1.2 libexec/httpd/ssl-bozo.c 1.14-1.16 libexec/httpd/tilde-luzah-bozo.c 1.10 libexec/httpd/libbozohttpd/Makefile 1.2 libexec/httpd/libbozohttpd/libbozohttpd.3 1.2-1.3 libexec/httpd/small/Makefile 1.2 Update bozohttpd from 20111118 to 20140708. changes in bozohttpd 20140708: o fixes for virtual host support, from rajeev_v_pillai@@yahoo.com o avoid printing double errors, from shm@@netbsd.org o fix a security issue in basic HTTP authentication which would allow authentication to be bypassed, from shm@@netbsd.org changes in bozohttpd 20140201: o support .svg files o fix a core dump when requests timeout changes in bozohttpd 20140102: o update a few content types o add support for directly calling lua scripts to handle processes, from mbalmer@@netbsd.org o properly escape generated HTML o add authentication for redirections, from martin@@netbsd.org o handle chained ssl certifications, from elric@@netbsd.org o add basic support for gzipped files, from elric@@netbsd.org o properly escape generated URIs @ text @a0 85 -- $NetBSD: printenv.lua,v 1.2 2014/01/02 08:21:38 mrg Exp $ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global veriables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. local httpd = require 'httpd' function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program if count == nil then count = 1 end -- output a header print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) print('module version: ' .. httpd._VERSION .. '
') print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do print(k .. '=' .. v .. '
') end print('

Request Headers

') for k, v in pairs(headers) do print(k .. '=' .. v .. '
') end if query ~= nil then print('

Query Variables

') for k, v in pairs(query) do print(k .. '=' .. v .. '
') end end print('

Form Test

') print([[
]]) -- output a footer print([[ ]]) end function form(env, header, query) if query ~= nil then print('

Form Variables

') if env.CONTENT_TYPE ~= nil then print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do print(k .. '=' .. v .. '
') end else print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.2.10.3 log @Pull up following revision(s) (requested by mrg in ticket #1377): libexec/httpd/CHANGES: up to 1.22 libexec/httpd/Makefile: up to 1.26 via patch libexec/httpd/auth-bozo.c: up to 1.18 libexec/httpd/bozohttpd.8: up to 1.59 libexec/httpd/bozohttpd.c: up to 1.80 via patch libexec/httpd/bozohttpd.h: up to 1.45 libexec/httpd/cgi-bozo.c: up to 1.33 libexec/httpd/content-bozo.c: up to 1.13 libexec/httpd/daemon-bozo.c: up to 1.17 libexec/httpd/dir-index-bozo.c: up to 1.25 libexec/httpd/lua-bozo.c: up to 1.14 libexec/httpd/lua/bozo.lua: up to 1.2 libexec/httpd/lua/glue.c: up to 1.2 libexec/httpd/main.c: up to 1.13 libexec/httpd/printenv.lua: up to 1.3 libexec/httpd/ssl-bozo.c: up to 1.22 libexec/httpd/testsuite/Makefile: up to 1.5 libexec/httpd/testsuite/t10.out: up to 1.2 libexec/httpd/testsuite/test-bigfile: up to 1.2 libexec/httpd/tilde-luzah-bozo.c: up to 1.14 Import bozohttpd 20151028: o add CGI support for ~user translation (-E switch) o add redirects to ~user translation o fix bugs around ~user translation o add schema detection for absolute redirects o fixed few memory leaks o bunch of minor tweaks o removed -r support o smarter redirects -- Changes in 20150320: o fix redirection handling o support transport stream (.ts) and video object (.vob) files o directory listings show correct file sizes for large files -- updates and bozohttpd 20160415: o add search-word support for CGI o fix a security issue in CGI suffix handler support which would allow remote code execution, from shm@@netbsd.org o -C option supports now CGI scripts only @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.2.10.2 2014/07/09 09:47:11 msaitoh Exp $ a10 4 -- You can test this example by running the following command: -- /usr/libexec/httpd -b -f -I 8080 -L test printenv.lua . -- and then navigate to: http://127.0.0.1:8080/test/printenv d18 6 a23 8 -- output headers using httpd.write() -- httpd.write() will not append newlines httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") -- output html using httpd.print() -- you can also use print() and io.write() but they will not work with SSL httpd.print([[ d32 1 a32 1 httpd.print('module version: ' .. httpd._VERSION .. '
') d34 1 a34 1 httpd.print('

Server Environment

') d37 1 a37 1 httpd.print(k .. '=' .. v .. '
') d40 1 a40 1 httpd.print('

Request Headers

') d42 1 a42 1 httpd.print(k .. '=' .. v .. '
') d46 1 a46 1 httpd.print('

Query Variables

') d48 1 a48 1 httpd.print(k .. '=' .. v .. '
') d52 1 a52 1 httpd.print('

Form Test

') d54 2 a55 2 httpd.print([[
d61 1 a61 1 httpd.print([[ a67 4 httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") d69 1 a69 1 httpd.print('

Form Variables

') d72 1 a72 1 httpd.print('Content-type: ' .. env.CONTENT_TYPE .. '
') d76 1 a76 1 httpd.print(k .. '=' .. v .. '
') d79 1 a79 1 httpd.print('No values') @ 1.2.8.1 log @file printenv.lua was added on branch netbsd-6-1 on 2014-07-09 09:44:56 +0000 @ text @d1 85 @ 1.2.8.2 log @Pull up following revision(s) (requested by mrg in ticket #1095): libexec/httpd/CHANGES 1.12-1.18 libexec/httpd/Makefile 1.13-1.22 libexec/httpd/Makefile.boot 1.6 libexec/httpd/auth-bozo.c 1.11-1.13 libexec/httpd/bozohttpd.8 1.33-1.46 libexec/httpd/bozohttpd.c 1.31-1.54 libexec/httpd/bozohttpd.h 1.21-1.32 libexec/httpd/cgi-bozo.c 1.21-1.25 libexec/httpd/content-bozo.c 1.8-1.10 libexec/httpd/daemon-bozo.c 1.16-1.16 libexec/httpd/dir-index-bozo.c 1.15-1.19 libexec/httpd/lua-bozo.c 1.1-1.9 libexec/httpd/main.c 1.6-1.7 libexec/httpd/netbsd_queue.h 1.1 libexec/httpd/printenv.lua 1.1-1.2 libexec/httpd/ssl-bozo.c 1.14-1.16 libexec/httpd/tilde-luzah-bozo.c 1.10 libexec/httpd/libbozohttpd/Makefile 1.2 libexec/httpd/libbozohttpd/libbozohttpd.3 1.2-1.3 libexec/httpd/small/Makefile 1.2 Update bozohttpd from 20111118 to 20140708. changes in bozohttpd 20140708: o fixes for virtual host support, from rajeev_v_pillai@@yahoo.com o avoid printing double errors, from shm@@netbsd.org o fix a security issue in basic HTTP authentication which would allow authentication to be bypassed, from shm@@netbsd.org changes in bozohttpd 20140201: o support .svg files o fix a core dump when requests timeout changes in bozohttpd 20140102: o update a few content types o add support for directly calling lua scripts to handle processes, from mbalmer@@netbsd.org o properly escape generated HTML o add authentication for redirections, from martin@@netbsd.org o handle chained ssl certifications, from elric@@netbsd.org o add basic support for gzipped files, from elric@@netbsd.org o properly escape generated URIs @ text @a0 85 -- $NetBSD: printenv.lua,v 1.2 2014/01/02 08:21:38 mrg Exp $ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global veriables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. local httpd = require 'httpd' function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program if count == nil then count = 1 end -- output a header print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) print('module version: ' .. httpd._VERSION .. '
') print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do print(k .. '=' .. v .. '
') end print('

Request Headers

') for k, v in pairs(headers) do print(k .. '=' .. v .. '
') end if query ~= nil then print('

Query Variables

') for k, v in pairs(query) do print(k .. '=' .. v .. '
') end end print('

Form Test

') print([[
]]) -- output a footer print([[ ]]) end function form(env, header, query) if query ~= nil then print('

Form Variables

') if env.CONTENT_TYPE ~= nil then print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do print(k .. '=' .. v .. '
') end else print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.2.8.3 log @Pull up following revision(s) (requested by mrg in ticket #1377): libexec/httpd/CHANGES: up to 1.22 libexec/httpd/Makefile: up to 1.26 via patch libexec/httpd/auth-bozo.c: up to 1.18 libexec/httpd/bozohttpd.8: up to 1.59 libexec/httpd/bozohttpd.c: up to 1.80 via patch libexec/httpd/bozohttpd.h: up to 1.45 libexec/httpd/cgi-bozo.c: up to 1.33 libexec/httpd/content-bozo.c: up to 1.13 libexec/httpd/daemon-bozo.c: up to 1.17 libexec/httpd/dir-index-bozo.c: up to 1.25 libexec/httpd/lua-bozo.c: up to 1.14 libexec/httpd/lua/bozo.lua: up to 1.2 libexec/httpd/lua/glue.c: up to 1.2 libexec/httpd/main.c: up to 1.13 libexec/httpd/printenv.lua: up to 1.3 libexec/httpd/ssl-bozo.c: up to 1.22 libexec/httpd/testsuite/Makefile: up to 1.5 libexec/httpd/testsuite/t10.out: up to 1.2 libexec/httpd/testsuite/test-bigfile: up to 1.2 libexec/httpd/tilde-luzah-bozo.c: up to 1.14 Import bozohttpd 20151028: o add CGI support for ~user translation (-E switch) o add redirects to ~user translation o fix bugs around ~user translation o add schema detection for absolute redirects o fixed few memory leaks o bunch of minor tweaks o removed -r support o smarter redirects -- Changes in 20150320: o fix redirection handling o support transport stream (.ts) and video object (.vob) files o directory listings show correct file sizes for large files -- updates and bozohttpd 20160415: o add search-word support for CGI o fix a security issue in CGI suffix handler support which would allow remote code execution, from shm@@netbsd.org o -C option supports now CGI scripts only @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.2.8.2 2014/07/09 09:44:56 msaitoh Exp $ a10 4 -- You can test this example by running the following command: -- /usr/libexec/httpd -b -f -I 8080 -L test printenv.lua . -- and then navigate to: http://127.0.0.1:8080/test/printenv d18 6 a23 8 -- output headers using httpd.write() -- httpd.write() will not append newlines httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") -- output html using httpd.print() -- you can also use print() and io.write() but they will not work with SSL httpd.print([[ d32 1 a32 1 httpd.print('module version: ' .. httpd._VERSION .. '
') d34 1 a34 1 httpd.print('

Server Environment

') d37 1 a37 1 httpd.print(k .. '=' .. v .. '
') d40 1 a40 1 httpd.print('

Request Headers

') d42 1 a42 1 httpd.print(k .. '=' .. v .. '
') d46 1 a46 1 httpd.print('

Query Variables

') d48 1 a48 1 httpd.print(k .. '=' .. v .. '
') d52 1 a52 1 httpd.print('

Form Test

') d54 2 a55 2 httpd.print([[
d61 1 a61 1 httpd.print([[ a67 4 httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") d69 1 a69 1 httpd.print('

Form Variables

') d72 1 a72 1 httpd.print('Content-type: ' .. env.CONTENT_TYPE .. '
') d76 1 a76 1 httpd.print(k .. '=' .. v .. '
') d79 1 a79 1 httpd.print('No values') @ 1.2.6.1 log @file printenv.lua was added on branch netbsd-6 on 2014-07-09 09:42:39 +0000 @ text @d1 85 @ 1.2.6.2 log @Pull up following revision(s) (requested by mrg in ticket #1095): libexec/httpd/CHANGES 1.12-1.18 libexec/httpd/Makefile 1.13-1.22 libexec/httpd/Makefile.boot 1.6 libexec/httpd/auth-bozo.c 1.11-1.13 libexec/httpd/bozohttpd.8 1.33-1.46 libexec/httpd/bozohttpd.c 1.31-1.54 libexec/httpd/bozohttpd.h 1.21-1.32 libexec/httpd/cgi-bozo.c 1.21-1.25 libexec/httpd/content-bozo.c 1.8-1.10 libexec/httpd/daemon-bozo.c 1.16-1.16 libexec/httpd/dir-index-bozo.c 1.15-1.19 libexec/httpd/lua-bozo.c 1.1-1.9 libexec/httpd/main.c 1.6-1.7 libexec/httpd/netbsd_queue.h 1.1 libexec/httpd/printenv.lua 1.1-1.2 libexec/httpd/ssl-bozo.c 1.14-1.16 libexec/httpd/tilde-luzah-bozo.c 1.10 libexec/httpd/libbozohttpd/Makefile 1.2 libexec/httpd/libbozohttpd/libbozohttpd.3 1.2-1.3 libexec/httpd/small/Makefile 1.2 Update bozohttpd from 20111118 to 20140708. changes in bozohttpd 20140708: o fixes for virtual host support, from rajeev_v_pillai@@yahoo.com o avoid printing double errors, from shm@@netbsd.org o fix a security issue in basic HTTP authentication which would allow authentication to be bypassed, from shm@@netbsd.org changes in bozohttpd 20140201: o support .svg files o fix a core dump when requests timeout changes in bozohttpd 20140102: o update a few content types o add support for directly calling lua scripts to handle processes, from mbalmer@@netbsd.org o properly escape generated HTML o add authentication for redirections, from martin@@netbsd.org o handle chained ssl certifications, from elric@@netbsd.org o add basic support for gzipped files, from elric@@netbsd.org o properly escape generated URIs @ text @a0 85 -- $NetBSD: printenv.lua,v 1.2 2014/01/02 08:21:38 mrg Exp $ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global veriables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. local httpd = require 'httpd' function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program if count == nil then count = 1 end -- output a header print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) print('module version: ' .. httpd._VERSION .. '
') print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do print(k .. '=' .. v .. '
') end print('

Request Headers

') for k, v in pairs(headers) do print(k .. '=' .. v .. '
') end if query ~= nil then print('

Query Variables

') for k, v in pairs(query) do print(k .. '=' .. v .. '
') end end print('

Form Test

') print([[
]]) -- output a footer print([[ ]]) end function form(env, header, query) if query ~= nil then print('

Form Variables

') if env.CONTENT_TYPE ~= nil then print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do print(k .. '=' .. v .. '
') end else print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.2.6.3 log @Pull up following revision(s) (requested by mrg in ticket #1377): libexec/httpd/CHANGES: up to 1.22 libexec/httpd/Makefile: up to 1.26 via patch libexec/httpd/auth-bozo.c: up to 1.18 libexec/httpd/bozohttpd.8: up to 1.59 libexec/httpd/bozohttpd.c: up to 1.80 via patch libexec/httpd/bozohttpd.h: up to 1.45 libexec/httpd/cgi-bozo.c: up to 1.33 libexec/httpd/content-bozo.c: up to 1.13 libexec/httpd/daemon-bozo.c: up to 1.17 libexec/httpd/dir-index-bozo.c: up to 1.25 libexec/httpd/lua-bozo.c: up to 1.14 libexec/httpd/lua/bozo.lua: up to 1.2 libexec/httpd/lua/glue.c: up to 1.2 libexec/httpd/main.c: up to 1.13 libexec/httpd/printenv.lua: up to 1.3 libexec/httpd/ssl-bozo.c: up to 1.22 libexec/httpd/testsuite/Makefile: up to 1.5 libexec/httpd/testsuite/t10.out: up to 1.2 libexec/httpd/testsuite/test-bigfile: up to 1.2 libexec/httpd/tilde-luzah-bozo.c: up to 1.14 Import bozohttpd 20151028: o add CGI support for ~user translation (-E switch) o add redirects to ~user translation o fix bugs around ~user translation o add schema detection for absolute redirects o fixed few memory leaks o bunch of minor tweaks o removed -r support o smarter redirects -- Changes in 20150320: o fix redirection handling o support transport stream (.ts) and video object (.vob) files o directory listings show correct file sizes for large files -- updates and bozohttpd 20160415: o add search-word support for CGI o fix a security issue in CGI suffix handler support which would allow remote code execution, from shm@@netbsd.org o -C option supports now CGI scripts only @ text @d1 1 a1 1 -- $NetBSD: printenv.lua,v 1.2.6.2 2014/07/09 09:42:39 msaitoh Exp $ a10 4 -- You can test this example by running the following command: -- /usr/libexec/httpd -b -f -I 8080 -L test printenv.lua . -- and then navigate to: http://127.0.0.1:8080/test/printenv d18 6 a23 8 -- output headers using httpd.write() -- httpd.write() will not append newlines httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") -- output html using httpd.print() -- you can also use print() and io.write() but they will not work with SSL httpd.print([[ d32 1 a32 1 httpd.print('module version: ' .. httpd._VERSION .. '
') d34 1 a34 1 httpd.print('

Server Environment

') d37 1 a37 1 httpd.print(k .. '=' .. v .. '
') d40 1 a40 1 httpd.print('

Request Headers

') d42 1 a42 1 httpd.print(k .. '=' .. v .. '
') d46 1 a46 1 httpd.print('

Query Variables

') d48 1 a48 1 httpd.print(k .. '=' .. v .. '
') d52 1 a52 1 httpd.print('

Form Test

') d54 2 a55 2 httpd.print([[
d61 1 a61 1 httpd.print([[ a67 4 httpd.write("HTTP/1.1 200 Ok\r\n") httpd.write("Content-Type: text/html\r\n\r\n") d69 1 a69 1 httpd.print('

Form Variables

') d72 1 a72 1 httpd.print('Content-type: ' .. env.CONTENT_TYPE .. '
') d76 1 a76 1 httpd.print(k .. '=' .. v .. '
') d79 1 a79 1 httpd.print('No values') @ 1.2.4.1 log @file printenv.lua was added on branch yamt-pagecache on 2014-05-22 11:37:13 +0000 @ text @d1 85 @ 1.2.4.2 log @sync with head. for a reference, the tree before this commit was tagged as yamt-pagecache-tag8. this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments") @ text @a0 85 -- $NetBSD$ -- this small Lua script demonstrates the use of Lua in (bozo)httpd -- it will simply output the "environment" -- Keep in mind that bozohttpd forks for each request when started in -- daemon mode, you can set global veriables here, but they will have -- the same value on each invocation. You can not keep state between -- two calls. local httpd = require 'httpd' function printenv(env, headers, query) -- we get the "environment" in the env table, the values are more -- or less the same as the variable for a CGI program if count == nil then count = 1 end -- output a header print([[ Bozotic Lua Environment

Bozotic Lua Environment

]]) print('module version: ' .. httpd._VERSION .. '
') print('

Server Environment

') -- print the list of "environment" variables for k, v in pairs(env) do print(k .. '=' .. v .. '
') end print('

Request Headers

') for k, v in pairs(headers) do print(k .. '=' .. v .. '
') end if query ~= nil then print('

Query Variables

') for k, v in pairs(query) do print(k .. '=' .. v .. '
') end end print('

Form Test

') print([[
]]) -- output a footer print([[ ]]) end function form(env, header, query) if query ~= nil then print('

Form Variables

') if env.CONTENT_TYPE ~= nil then print('Content-type: ' .. env.CONTENT_TYPE .. '
') end for k, v in pairs(query) do print(k .. '=' .. v .. '
') end else print('No values') end end -- register this handler for http:////printenv httpd.register_handler('printenv', printenv) httpd.register_handler('form', form) @ 1.1 log @add Lua scripting support to bozohttpd, see httpd(8) for details @ text @d1 2 @