toymaker.git

commit cd100eeb6673a33c46261d1b1d1a2f9a283433f6

Author: Adam Evyčędo <git@apiote.xyz>

fix serving artifacts

 get.sh | 2 +-
 toymaker.sh | 4 ++--


diff --git a/get.sh b/get.sh
index 2837c03c6856270e940456354d607fa9570a0282..78373bbedda88e1341aefb6892da98468439deac 100644
--- a/get.sh
+++ b/get.sh
@@ -71,7 +71,7 @@ 	if [ ! -f "toys/$toy/$item/$artifactName" ]
 	then
 		printf 'n;'
 	else
-		contentType=$(file -b -i "toys/$toy/$item/$artifactName")
+		contentType=$(file -b -i "toys/$toy/$item/$artifactName" | cut -d ';' -f1)
 		printf '0;%s;%s' "$contentType" "toys/$toy/$item/$artifactName"
 	fi
 }




diff --git a/toymaker.sh b/toymaker.sh
index 5aaa98cce21d7758fbc635a0cce1d01784d92d0d..6b61e90a817c42b8f8b32899a904894721e3d24e 100755
--- a/toymaker.sh
+++ b/toymaker.sh
@@ -95,12 +95,12 @@ 	contentType="$2"
 
 	{ cat "$fifo2" > /dev/null; printf ""; } > "$fifo1" &
 
-	printf "HTTP/1.1 200 OK\r\nContent-Length: %s\r\nContent-Type: %s\r\n\r\n" "${#page}" "$contentType" >> "$fifo1"
+	printf "HTTP/1.1 200 OK\r\nContent-Length: %s\r\nContent-Type: %s\r\n\r\n" "$(wc -c "$filePath" | cut -d ' ' -f1)"  "$contentType" >> "$fifo1"
 
 	cat "$filePath" >> "$fifo1"
 
 	sleep 1; echo "end" > "$fifo2"
-	printf "200 %s" "${#page}"
+	printf "200 %s" "$(wc -c "$filePath" | cut -d ' ' -f1)"
 }
 
 respond202() {