From ba840b5d0d7756afd6edbed883ddcf09459b02db Mon Sep 17 00:00:00 2001 From: bronku Date: Tue, 25 Nov 2025 12:16:48 +0100 Subject: [PATCH] demo script --- demonstration.sh | 32 +++++++++++++++++++ .../spring_boot/MirrorController.java | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 demonstration.sh diff --git a/demonstration.sh b/demonstration.sh new file mode 100755 index 0000000..4733531 --- /dev/null +++ b/demonstration.sh @@ -0,0 +1,32 @@ +echo "Testing .NET app routing (load balancing):" +for i in {1..10}; do + curl -s -H "X-App-Type: dotnet" http://localhost/ | grep "Server Name" + sleep 0.1 +done + +echo "" +echo "Testing Java app routing (load balancing):" +for i in {1..10}; do + curl -s -H "X-App-Type: java" http://localhost/ | grep "Server Name" + sleep 0.1 +done + +echo "" +echo "Waiting 3 seconds before rate limiting test..." +sleep 3 + +echo "Testing rate limiting (50 rapid requests):" +success=0 +limited=0 +for i in {1..50}; do + response=$(curl -H "X-App-Type: dotnet" http://localhost/ -w "%{http_code}" -s -o /dev/null) + if [ "$response" == "200" ]; then + success=$((success + 1)) + elif [ "$response" == "503" ]; then + limited=$((limited + 1)) + fi +done + +echo "Results:" +echo " Successful (200): $success" +echo " Rate Limited (503): $limited" diff --git a/java/src/main/java/java_app/spring_boot/MirrorController.java b/java/src/main/java/java_app/spring_boot/MirrorController.java index 0ebc467..06b8caf 100644 --- a/java/src/main/java/java_app/spring_boot/MirrorController.java +++ b/java/src/main/java/java_app/spring_boot/MirrorController.java @@ -46,6 +46,6 @@ public class MirrorController { .append("\n"); }); - return "
" + responseText.toString() + "
\n"; + return "
\n" + responseText.toString() + "
\n"; } }