From ebbcdae62c9e42d501ef5ab02046761f3be4603b Mon Sep 17 00:00:00 2001
From: Santo Cariotti <santo@dcariotti.me>
Date: Fri, 22 Oct 2021 23:08:40 +0200
Subject: fix parsing of first header line

---
 Year_3/TSDWL/webserver/server.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'Year_3')

diff --git a/Year_3/TSDWL/webserver/server.c b/Year_3/TSDWL/webserver/server.c
index 15c8117..66ca8bf 100644
--- a/Year_3/TSDWL/webserver/server.c
+++ b/Year_3/TSDWL/webserver/server.c
@@ -355,11 +355,11 @@ main(int argc, char* argv[])
         if (headers_num == 0) {
             buffer = "You must specify almost one header\n";
             write(clientfd, buffer, strlen(buffer) + 1);
-        }
-
-        if (parse_first_line(&request, headers[0], strlen(headers[0])) > -1) {
-            if (request.method == GET) {
-                read_file(www_path, &request, clientfd);
+        } else {
+            if (parse_first_line(&request, headers[0], strlen(headers[0])) > -1) {
+                if (request.method == GET) {
+                    read_file(www_path, &request, clientfd);
+                }
             }
         }
 
-- 
cgit v1.2.3-18-g5258