Skip to content

Commit 7a2b868

Browse files
committed
receiving bytes on proxy and sending directly to client
1 parent d64f85b commit 7a2b868

20 files changed

Lines changed: 938 additions & 108 deletions

Makefile

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,54 @@
11
CC=gcc
2+
CC_FLAGS_OBJ=gcc -o
23
CFLAGS=-c -g -pthread -D_GNU_SOURCE
4+
35
SOURCE_DIR=src
46
OBJ_DIR=obj
7+
BIN_DIR=bin
8+
59
HTTP_SCRIPT=$(SOURCE_DIR)/http2.c
610
HTTP_OBJ=$(OBJ_DIR)/http2.o
711

8-
all: bin/client bin/server
12+
SERVER_SCRIPT=$(SOURCE_DIR)/server.c
13+
SERVER_OBJ=$(OBJ_DIR)/server.o
14+
SERVER_BIN=$(BIN_DIR)/server
15+
16+
CLIENT_SCRIPT=$(SOURCE_DIR)/client.c
17+
CLIENT_OBJ=$(OBJ_DIR)/client.o
18+
CLIENT_BIN=$(BIN_DIR)/client
19+
20+
HISTORY_SCRIPT=$(SOURCE_DIR)/history.c
21+
HISTORY_OBJ=$(OBJ_DIR)/history.o
22+
23+
LIST_SCRIPT=$(SOURCE_DIR)/argsList.c
24+
LIST_OBJ=$(OBJ_DIR)/argsList.o
25+
26+
COMM_SCRIPT=$(SOURCE_DIR)/communication.c
27+
COMM_OBJ=$(OBJ_DIR)/communication.o
28+
29+
HASH_SCRIPT=$(SOURCE_DIR)/hashServer2.c
30+
HASH_OBJ=$(OBJ_DIR)/hashServer2.o
31+
32+
DIREC_SCRIPT=$(SOURCE_DIR)/directories.c
33+
DIREC_OBJ=$(OBJ_DIR)/directories.o
34+
35+
36+
all: $(CLIENT_BIN) $(SERVER_BIN)
937

10-
bin/client: obj/client.o obj/history.o obj/argsList.o obj/communication.o obj/directories.o
11-
gcc -o bin/client obj/client.o obj/history.o obj/argsList.o obj/communication.o obj/directories.o -pthread
38+
bin/client: $(CLIENT_OBJ) $(HISTORY_OBJ) $(LIST_OBJ) $(COMM_OBJ) $(DIREC_OBJ)
39+
$(CC_FLAGS_OBJ) $(CLIENT_BIN) $(CLIENT_OBJ) $(HISTORY_OBJ) $(LIST_OBJ) $(COMM_OBJ) $(DIREC_OBJ) -pthread
1240

13-
obj/client.o: src/client.c src/history.c src/argsList.c src/communication.c
14-
$(CC) $(CFLAGS) src/client.c src/history.c src/argsList.c src/communication.c src/directories.c
15-
mv *.o obj/
41+
obj/client.o: $(CLIENT_SCRIPT) $(HISTORY_SCRIPT) $(LIST_SCRIPT) $(COMM_SCRIPT)
42+
$(CC) $(CFLAGS) $(CLIENT_SCRIPT) $(HISTORY_SCRIPT) $(LIST_SCRIPT) $(COMM_SCRIPT) $(DIREC_SCRIPT)
43+
mv *.o $(OBJ_DIR)/
1644

17-
bin/server: obj/server.o obj/hashServer.o obj/communication.o $(HTTP_OBJ) obj/directories.o
18-
gcc -o bin/server obj/server.o obj/hashServer.o obj/communication.o $(HTTP_OBJ) obj/directories.o -pthread
45+
bin/server: $(SERVER_OBJ) $(HASH_OBJ) $(COMM_OBJ) $(HTTP_OBJ) $(DIREC_OBJ)
46+
$(CC_FLAGS_OBJ) $(SERVER_BIN) $(SERVER_OBJ) $(HASH_OBJ) $(COMM_OBJ) $(HTTP_OBJ) $(DIREC_OBJ) -pthread
1947

20-
obj/server.o: src/server.c src/hashServer.c src/communication.c $(HTTP_SCRIPT) src/directories.c
21-
$(CC) $(CFLAGS) src/server.c src/hashServer.c src/communication.c $(HTTP_SCRIPT) src/directories.c
22-
mv *.o obj/
48+
obj/server.o: $(SERVER_SCRIPT) $(HASH_SCRIPT) $(COMM_SCRIPT) $(HTTP_SCRIPT) $(DIREC_SCRIPT)
49+
$(CC) $(CFLAGS) $(SERVER_SCRIPT) $(HASH_SCRIPT) $(COMM_SCRIPT) $(HTTP_SCRIPT) $(DIREC_SCRIPT)
50+
mv *.o $(OBJ_DIR)/
2351

2452
clean:
25-
rm clients/client1/* clients/client2/* clients/client3/* proxy/* infoPage/* obj/* bin/*
53+
rm clients/client1/* clients/client2/* clients/client3/* proxy/* infoPage/* $(OBJ_DIR)/* $(BIN_DIR)/*
2654
clear

bin/client

4.75 KB
Binary file not shown.

bin/server

-352 Bytes
Binary file not shown.

clients/client1/file1.html

Lines changed: 284 additions & 0 deletions
Large diffs are not rendered by default.

clients/client1/hello.html

Whitespace-only changes.

include/hashServer.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,30 @@
1111
#define TABLE_SIZE 10
1212

1313
typedef struct LinkedList{
14+
struct LinkedList * next;
1415
char * site;
1516
int content_length;
1617
time_t creation_time;
17-
struct LinkedList * next;
1818
}LinkedList;
1919

2020
typedef struct Hash{
21+
LinkedList * begin; // Ponteiro para head da LinkedList
2122
int n_elements; // Número de elementos da lista encadeada
22-
LinkedList * begin; // Ponteiro para head da LinkedList
2323
}Hash;
24-
24+
/*
2525
int hashFunction( char * );
2626
LinkedList * createNode( char * , int, Hash [] );
2727
void removeHash( Hash [] );
2828
LinkedList * remove_Hash_Node ( LinkedList *, LinkedList*, int, Hash [] );
2929
void printHash( Hash [] );
3030
LinkedList * searchInHash( char * , Hash [] );
31+
*/
32+
33+
int hashFunction( char * );
34+
LinkedList * createNode( char * , int, Hash ** );
35+
void removeHash( Hash ** );
36+
void printHash( Hash ** );
37+
LinkedList * searchInHash( char * , Hash ** );
38+
LinkedList * remove_Hash_Node ( LinkedList * , LinkedList * , int, Hash ** );
3139

3240
#endif

infoPage/file1.html.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HTTP/1.1 200 OK
2+
Date: Mon, 18 Oct 2021 01:00:41 GMT
3+
Server: Apache/2.4.38 (Debian)
4+
Last-Modified: Thu, 09 Sep 2021 15:20:45 GMT
5+
ETag: "30372-5cb918aec6d40"
6+
Accept-Ranges: bytes
7+
Content-Length: 197490
8+
Vary: Accept-Encoding
9+
Connection: close
10+
Content-Type: text/html
11+
Set-Cookie: BACKENDID=backend_PnWtF_omega03|YWzHP|YWzHP; path=/
12+

infoPage/hello.html.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
HTTP/1.1 200 OK
2+
Date: Mon, 18 Oct 2021 01:00:41 GMT
3+
Server: Apache/2.4.38 (Debian)
4+
Last-Modified: Thu, 09 Sep 2021 15:20:24 GMT
5+
ETag: "30-5cb9189abfe00"
6+
Accept-Ranges: bytes
7+
Content-Length: 48
8+
Connection: close
9+
Content-Type: text/html
10+
Set-Cookie: BACKENDID=backend_PnWtF_omega03|YWzHP|YWzHP; path=/
11+

obj/client.o

3.26 KB
Binary file not shown.

obj/hashServer.o

-10.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)