diff options
author | Matt Strapp <strap012@umn.edu> | 2020-12-10 11:03:43 -0600 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2020-12-10 11:03:43 -0600 |
commit | 2b88c3ace2fe3395b5fdc20d29c2c3f762023121 (patch) | |
tree | a7a0117f63ec36269823dfed54319313825d728d | |
parent | add error handling (diff) | |
download | csci4061-2b88c3ace2fe3395b5fdc20d29c2c3f762023121.tar csci4061-2b88c3ace2fe3395b5fdc20d29c2c3f762023121.tar.gz csci4061-2b88c3ace2fe3395b5fdc20d29c2c3f762023121.tar.bz2 csci4061-2b88c3ace2fe3395b5fdc20d29c2c3f762023121.tar.lz csci4061-2b88c3ace2fe3395b5fdc20d29c2c3f762023121.tar.xz csci4061-2b88c3ace2fe3395b5fdc20d29c2c3f762023121.tar.zst csci4061-2b88c3ace2fe3395b5fdc20d29c2c3f762023121.zip |
add temporary header print
-rw-r--r-- | P4/util.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -110,6 +110,7 @@ int get_request(int fd, char *filename) { char get[100], http[100]; recv(fd, buffer, 2048, 0); + //--ERROR HANDLING-- if(sscanf(buffer, "%s %s %s", get, filename, http) < 2) { // Read HTTP Get request and parse if (close(fd) == -1) { perror("Socket close error"); @@ -117,7 +118,9 @@ int get_request(int fd, char *filename) { } return -1; } - else if (strcmp(get, "GET")) { + //Print header + printf("%s %s %s\n", get, filename, http); + if (strcmp(get, "GET")) { if (close(fd) == -1) { perror("Socket close error"); return -15; @@ -125,7 +128,7 @@ int get_request(int fd, char *filename) { printf("Not a GET\n"); return -2; } - else if (strlen(filename) > 1023) { + if (strlen(filename) > 1023) { if (close(fd) == -1) { perror("Socket close error"); return -15; @@ -133,6 +136,7 @@ int get_request(int fd, char *filename) { printf("Not sure but bad\n"); return -3; } + //--END ERROR HANDLING-- for (int i=0; i<strlen(filename); i++) { if ((strstr(filename, "//")) != 0 || (strstr(filename, "..")) != 0) { if (close(fd) == -1) { |