Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for index.htm files #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Limitations:
2. Doesn't strictly adhere to the HTTP spec.

Security:
1. Only rudimentary input handling. We would not running this on a public machine.
1. Only rudimentary input handling. We would not recommend running this on a public machine.

HTTP protocol support:
403: Returned when a directory is not listable, or a file is not readable
Expand Down
10 changes: 8 additions & 2 deletions bashttpd
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,14 @@ serve_dir_or_file_from() {
[[ $URL_PATH == *..* ]] && fail_with 400

# Serve index file if exists in requested directory
[[ -d $URL_PATH && -f $URL_PATH/index.html && -r $URL_PATH/index.html ]] && \
URL_PATH="$URL_PATH/index.html"
FILE_LIST=('index.html' 'index.htm')
if [[ -d "$URL_PATH" ]]; then
for FILE in "${FILE_LIST[@]}"; do
[[ -f "$URL_PATH/$FILE" && -r "$URL_PATH/$FILE" ]] && \
URL_PATH="$URL_PATH/$FILE" && break
done
fi


if [[ -f $URL_PATH ]]; then
[[ -r $URL_PATH ]] && \
Expand Down