Skip to content

Commit 48c2f25

Browse files
committed
Check for existence of $DOCROOT.
1 parent d649bc4 commit 48c2f25

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

bashttpd.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ function get_content_length() {
4747
CONTENT_LENGTH=$( echo ${CONTENT_BODY} | wc -c )
4848
}
4949

50+
function serve_500() {
51+
echo "HTTP/1.0 500 Internal Server Error"
52+
echo "$REPLY_HEADERS"
53+
echo "Content-Type: text/plain"
54+
echo
55+
echo "Internal Server Error"
56+
exit
57+
}
58+
59+
if ! [ -d "$DOCROOT" ]; then
60+
echo >&2 "Error: \$DOCROOT '$DOCROOT' does not exist."
61+
serve_500
62+
fi
63+
5064
while read line; do
5165
# If we've reached the end of the headers, break.
5266
line=$( echo ${line} | tr -d '\r' )

0 commit comments

Comments
 (0)