Moving poc under testutils directory.

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2020-01-24 11:41:52 +01:00
parent f103b39a94
commit dd8b5895bd
15 changed files with 249 additions and 409 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
BASE="$1"
PATHNAME="$2"
REAL="$(realpath --relative-base="$BASE" "$BASE/$PATHNAME")"
if [ ! -f "$BASE/$PATHNAME" ]; then
kapow set /response/status 404
exit
else
case $REAL in
"/"*)
kapow set /response/status 403
exit
;;
*)
kapow set /response/status 200
kapow set /response/headers/Content-Type "$(python -m mimetypes "$BASE/$REAL" | awk '/type:/ {print $2; exit 0}; !/type:/ {print "application/octet-stream"}')"
kapow set /response/body < "$BASE/$REAL"
esac
fi