Skip to content

dzove855/Bash-web-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash-web-server

A purely bash web server, no socat, netcat, etc...

Requirement

How to

The port can be set by the env var: HTTP_PORT

The path to accept (Directory) can be set by using: BASH_LOADABLE_PATH

Server Methods:

  • serverHtml (needs DOCUMENT_ROOT envvars) - This will serve the static files
  • script file - The script need a file as first argument which will be source. The file will need a function named runner, which will be run on each request

Problems...

Well there's a little problem... since accept doesn't close the connection (Or i'm doing something wrong), the connection will go into TIME_WAIT. This means that we need to wait the time the connection will be closed, after that we can reopen a connection. I will have a look at the source code and probably provide some options, like a bind-address and a close when the FD is closed.

UPDATE:

Accept has been patched by me. Now we can handle multiple request at the same time, without waiting the TIME_WAIT.

To use the new accept, you will need to compile the accept from this repo, a pull request will be send to bash, but it will take some time.

Now we can run multiple connection on the same time, since the connection is running in a subshell.

Busion

Busion is used to source some functions from other repositorys instead of copy/paste (https://github.com/dzove855/busion)

TODO

  • Implement logging and provide a logging format like httpd
  • Implement multi processing (this will be a huge step, but we need to patch accept)
  • Implement urlencode/decode to provide readable get data
  • Implement content-type detection - Use mime type like nginx
  • Add basic auth

About

A purely bash web server, no socat, netcat, etc...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages