Skip to content

Commit

Permalink
Started with the support of compression
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoKrupitza committed Feb 26, 2020
1 parent 30d5d10 commit 8164ac4
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CC = gcc
DEFS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_POSIX_C_SOURCE=200809L

CFLAGS = -Wall -Wno-unused-function -g -std=c99 -pedantic $(DEFS)
SERVEROBJECTS = server.o httpHeaderManager.o permissions.o mimeTypeManager.o messageHandler.o
SERVEROBJECTS = server.o httpHeaderManager.o permissions.o mimeTypeManager.o messageHandler.o compressionHandler.o
.PHONY: all clean

all: clean httpc
Expand All @@ -18,6 +18,7 @@ httpHeaderManager.o: httpHeaderManager.c httpHeaderManager.h httpStatusCodes.h
messageHandler.o: messageHandler.c messageHandler.h httpHeaderManager.c httpHeaderManager.h
permissions.o: permissions.c permissions.h httpStatusCodes.h httpHeaderManager.h
mimeTypeManager.o: mimeTypeManager.c mimeTypeManager.h permissions.h
compressionHandler.o: compressionHandler.c compressionHandler.h

clean:
rm -rf *.o httpc
6 changes: 6 additions & 0 deletions compressionHandler.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "compressionHandler.h"

char *compressString(char *content, compression_t type, char *compressed)
{
return content;
}
43 changes: 43 additions & 0 deletions compressionHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <strings.h>

typedef enum
{
GZIP,
COMPRESS,
DEFLATE,
IDENTITY,
BR,
UNDEFINED
} compression_t;

char *compressString(char *content, compression_t type, char *compressed);

compression_t getEnumFromChar(char *type)
{
if (strcasecmp("gzip", type) == 0)
{
return GZIP;
}
else if (strcasecmp("compress", type) == 0)
{
return COMPRESS;
}
else if (strcasecmp("deflate", type) == 0)
{
return DEFLATE;
}
else if (strcasecmp("br", type) == 0)
{
return BR;
}
else if (strcasecmp("identity", type) == 0)
{
return IDENTITY;
}
else if (strcasecmp("*", type) == 0)
{
//DEFAULT we just use GZIP
return GZIP;
}
return UNDEFINED;
}
1 change: 1 addition & 0 deletions httpHeaderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef struct
char *connection;
char *user_agent;
char *accept_encoding;
char *content_encoding;
int content_length;
char *content_type;
char *date;
Expand Down
Binary file modified httpc
Binary file not shown.

0 comments on commit 8164ac4

Please sign in to comment.