mirror of
https://git.sakamoto.pl/domi/http.sh
synced 2026-05-25 11:03:28 -04:00
master
this seems deliciously simple until you attempt it. we no longer do automatic mimetype generation because it's *impossible* to do it for dynamic pages without keeping a tempfile, or inventing time travel. I tried splitting the fd's with tee, then using one to buffer the data, and another to capture the mimetype. sadly, there's a circular dependency between releasing and capturing data, so unless you're happy with your data going straight to stdout, it's impossible to use fd's as they were intended. also, if your fd's are cross-dependent on each other, you're gonna suffer. what's up with the tail invocations? we need someone to "timeshift" our data; tail has to block the I/O so the output doesn't leak out to stdout before we print headers. it's waiting for 2GB of data which will (hopefully) never happen. finger's crossed. anyways, once we're done with the headers, we close the fd, which releases all the output to the socket. lastly, wait is there to make sure we don't close the connection too early.
HTTP.sh
the coolest web framework (in Bash) to date.
We now have an IRC channel! Join #http.sh @ irc.libera.chat
Documentation
We have some guides and general documentation in the docs directory. Among them:
- A quick start guide
- General directory structure
- CLI usage
- Tests
- HTTP Router
- Template engine
- Script integrations
- HTTP request API
- List of security fixes
Dependencies
Absolutely necessary:
- Bash (5.x, not interested in backwards compat)
- either Ncat (not openbsd-nc, not netcat, not nc) or socat, or a combo of both
- GNU grep/sed
Full list of dependencies: required, optional.
Known faults
- if ncat fails to bind to
[::], change the bind to127.0.0.1or0inconfig/master.sh $post_multipartdoesn't keep original names - could be fixed by parsing individual headers from the multipart request instead of skipping them all- websocket impl isn't properly finished
- fails with an empty response, instead of throwing 400/500
Variables that we think are cool!
(this data may be slightly outdated. Full docs TODO.)
- get_data - holds data from GET parameters
- /?test=asdf ->
${get_data[test]}=="asdf"
- /?test=asdf ->
- params - holds parsed data from URL router
- /profile/test (assuming profile/:name) ->
${params[name]}=="test"
- /profile/test (assuming profile/:name) ->
- post_data - same as above, but for urlencoded POST params
- test=asdf ->
${post_data[test]}=="asdf"
- test=asdf ->
- post_multipart - contains paths to uploaded files from multipart/form-data POST requests. WARNING: it doesn't hold field names yet, it relies on upload order for identification
- first file (in upload order) ->
cat ${post_multipart[0]} - second file ->
cat ${post_multipart[1]}
- first file (in upload order) ->
- r - misc request data
- authorization
- content_boundary
- content_boundary
- content_length
- content_type
- headers
- host
- host_portless
- ip
- post
- proto
- status
- uri
- url
- user_agent
- view
- websocket_key
- cfg - server and app config - see
config/master.shfor more details
Fun stuff
- To prevent running malicious scripts, by default only scripts with extension
.shscan be run by the server, but this can be changed in the config. - ${cfg[index]} ignores the above - see config/master.sh
- Trans rights!
- SHS stands for Shell Server.
Description
Languages
Shell
99.7%
Dockerfile
0.3%
