diff --git a/http-server.c b/http-server.c index 7ba28a6415c7004742ba363a7ed533197560b71d..13af6799727ce5138dc19e000c86322485a1f88e 100644 --- a/http-server.c +++ b/http-server.c @@ -36,6 +36,7 @@ static int const HTTP_404_LENGTH = 45; static int user1 = -1; static int user1_start = 0; + static int user2 = -1; static int user2_start = 0; @@ -91,14 +92,18 @@ static bool handle_http_request(int sockfd) while (*curr == '.' || *curr == '/'){ ++curr; } - printf("I AM THE CURRENT: %s\n\n\n", curr); - // assume the only valid request URI is "/" but it can be modified to accept more files - if (*curr == ' ') { + + if (strlen(curr) > 0) { + if (method == GET) { if( strstr(buff, "?start=Start") != NULL ){ + if(sockfd == user1){ + user1_start = 1; + } else if(sockfd == user2){ + user2_start = 1; + } webpage = "html/3_first_turn.html"; - printf("\n\n\nWORKING\n\n\n"); } else { webpage = "html/1_intro.html"; } @@ -150,9 +155,11 @@ static bool handle_http_request(int sockfd) // get the size of the file struct stat st; stat(webpage, &st); + // increase file size to accommodate the username long size = st.st_size + added_length; n = sprintf(buff, HTTP_200_FORMAT, size); + // send the header first if (write(sockfd, buff, n) < 0) { diff --git a/server b/server index c2e65dfd92cdeefb5259329cea9670ab310390c1..fc50a3489cdca35b6da89c6b3962d7536bcc09c3 100755 Binary files a/server and b/server differ