diff --git a/2A/Reseaux/.server.sh.swo b/2A/Reseaux/.server.sh.swo new file mode 100644 index 0000000..3d25644 Binary files /dev/null and b/2A/Reseaux/.server.sh.swo differ diff --git a/2A/Reseaux/server.sh b/2A/Reseaux/server.sh new file mode 100755 index 0000000..b1fabe0 --- /dev/null +++ b/2A/Reseaux/server.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# set -x + +if [ "$1" != '-server' ]; then + socat TCP-LISTEN:2000,fork,reuseaddr EXEC:"$0 -server"; exit $? +fi + +case $@ in + '-server') + read request + method=$(echo $request | cut -d " " -f 1) + fich=$(echo $request | cut -d " " -f 2) + if [ $fich = "/" ]; then + fich="/index.html" + fi + + fich="./www-test/${fich:1}" + + + if [ $method != 'GET' ]; then + echo -e -n "HTTP/1.1 403 Forbiden\r\n" + echo -e -n "Content-Length: 14 \r\n" + echo -e -n "Connection: close\r\n" + echo -e -n "Content-Type: text/plain\r\n" + echo -e -n "\r\n" + echo -e -n "403 : Forbiden\n";echo -n "Erreur 403" >&2;exit $? + + fi + if [ ! -f $fich ]; then + echo -e -n "HTTP/1.1 404 Not found\r\n" + echo -e -n "Server: Apache/2.2.22 (Debian)\r\n" + echo -e -n "Accept-Ranges: bytes\r\n" + echo -e -n "Content-Length: 15\r\n" + echo -e -n "Content-Type: $mine\r\n" + echo -e -n "Connection: close\r\n" + echo -e -n "\r\n" + echo -n "404 : Not Found";echo "Erreur 404" >&2 + fi + + mime=$(file -L --brief --mime-type $fich) + + echo -e -n "HTTP/1.1 200 OK\r\n" + echo -e -n "Server: Apache/2.2.22 (Debian)\r\n" + echo -e -n "Accept-Ranges:bytes\r\n" + echo -e -n "Content-Length: $(cat $fich | wc -c)\r\n" + echo -e -n "Content-Type: $mine\r\n" + echo -e -n "Connection: close\r\n" + echo -e -n "\r\n" + + cat $fich + + ;; +esac diff --git a/2A/Reseaux/www-test/favicon.ico b/2A/Reseaux/www-test/favicon.ico new file mode 100644 index 0000000..674ca8e Binary files /dev/null and b/2A/Reseaux/www-test/favicon.ico differ diff --git a/2A/Reseaux/www-test/imgs/img.gif b/2A/Reseaux/www-test/imgs/img.gif new file mode 100644 index 0000000..f575aa4 Binary files /dev/null and b/2A/Reseaux/www-test/imgs/img.gif differ diff --git a/2A/Reseaux/www-test/index.html b/2A/Reseaux/www-test/index.html new file mode 120000 index 0000000..6d70cd0 --- /dev/null +++ b/2A/Reseaux/www-test/index.html @@ -0,0 +1 @@ +test.html \ No newline at end of file diff --git a/2A/Reseaux/www-test/style.css b/2A/Reseaux/www-test/style.css new file mode 100644 index 0000000..e15c3e9 --- /dev/null +++ b/2A/Reseaux/www-test/style.css @@ -0,0 +1,36 @@ +html, body { + margin: 0; + padding: 0; + } +body { + background-color: white; + font-family: Verdana, sans-serif; + font-size: 100%; + } +h1 { + font-size: 200%; + color: navy; + text-align: center; + } +h2 { + font-size: 150%; + color: red; + padding-left: 15px; + } +p,ul,li,td { + color: black; + } +a:link { + color: green; + text-decoration: underline; + } +a:visited { + color: gray; + } +a:hover { + color: red; + text-decoration: none; +} +a:active, a:focus { + color: red; +} diff --git a/2A/Reseaux/www-test/test-img-css.html b/2A/Reseaux/www-test/test-img-css.html new file mode 100644 index 0000000..90f7d12 --- /dev/null +++ b/2A/Reseaux/www-test/test-img-css.html @@ -0,0 +1,19 @@ + +
++Source +
+Source +