aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-12-10 11:03:43 -0600
committerMatt Strapp <strap012@umn.edu>2020-12-10 11:03:43 -0600
commit2b88c3ace2fe3395b5fdc20d29c2c3f762023121 (patch)
treea7a0117f63ec36269823dfed54319313825d728d
parentadd error handling (diff)
downloadcsci4061-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.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/P4/util.c b/P4/util.c
index 3967767..07a18ef 100644
--- a/P4/util.c
+++ b/P4/util.c
@@ -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) {