aboutsummaryrefslogtreecommitdiffstats
path: root/P3
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-11-15 18:40:03 -0600
committerMatt Strapp <strap012@umn.edu>2020-11-15 18:40:03 -0600
commitfdf2317e70c9446ac06f21176773ee745fb20cfa (patch)
treea8fa22e7d0a93ca35de0f6aa95ab6790223513f7 /P3
parentdo many things (diff)
parentAdded getContentType (diff)
downloadcsci4061-fdf2317e70c9446ac06f21176773ee745fb20cfa.tar
csci4061-fdf2317e70c9446ac06f21176773ee745fb20cfa.tar.gz
csci4061-fdf2317e70c9446ac06f21176773ee745fb20cfa.tar.bz2
csci4061-fdf2317e70c9446ac06f21176773ee745fb20cfa.tar.lz
csci4061-fdf2317e70c9446ac06f21176773ee745fb20cfa.tar.xz
csci4061-fdf2317e70c9446ac06f21176773ee745fb20cfa.tar.zst
csci4061-fdf2317e70c9446ac06f21176773ee745fb20cfa.zip
Fix merge conflict
Diffstat (limited to 'P3')
-rw-r--r--P3/server.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/P3/server.c b/P3/server.c
index 9c8f372..a1d0527 100644
--- a/P3/server.c
+++ b/P3/server.c
@@ -78,14 +78,31 @@ void initCache(){
char* getContentType(char * mybuf) {
// Should return the content type based on the file type in the request
// (See Section 5 in Project description for more details)
+ char* ext = strrchr(mybuf, '.');
-
+ if (ext == NULL) {
+ printf("Filetype not found. Exiting\n");
+ exit(-1);
+ }
+ else if ((!strcmp((ext + 1), "htm")) || (!strcmp((ext + 1), "html"))) {
+ return "text/html";
+ }
+ else if (!strcmp((ext + 1), "jpg")) {
+ return "image/jpeg";
+ }
+ else if (!strcmp((ext + 1), "gif")) {
+ return "image/gif";
+ }
+ else {
+ return "text/plain";
+ }
}
// Function to open and read the file from the disk into the memory
// Add necessary arguments as needed
int readFromDisk(/*necessary arguments*/) {
// Open and read the contents of file given the request
+
}
/**********************************************************************************/
@@ -198,7 +215,10 @@ int main(int argc, char **argv) {
return -1;
}
// Initialize cache (extra credit B)
+<<<<<<< HEAD
+=======
+>>>>>>> startmain
// Start the server
init(port);
// Create dispatcher threads (make detachable????)