Skip to content
Snippets Groups Projects
Commit 72c400af authored by Paul Ripault's avatar Paul Ripault
Browse files

fin tp5 ?

parent a9c571bf
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,14 @@
char* testCorrect(char* str, int first){
char* testCorrect(char* str, int first, char* buf){
int i = strlen(str);
char* strRet;
char *correctStr = "GET / HTTP/1.1";
char *incorrectStr = "HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-Length: 17\r\n\r\n400 Bad request";
char *correctStr2 = "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 17\r\n\r\n200 OK";
sprintf(buf,"HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-Length: %d\r\n\r\n400 Bad request",i);
char *incorrectStr= buf;
sprintf(buf,"HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: %d\r\n\r\n200 OK", i);
char *correctStr2= buf;
if(strstr(str,correctStr) == NULL && first == 0) {
strRet=incorrectStr;
//printf("---\n%s\n---",str);
......@@ -44,8 +47,9 @@ int traitementClient(int socket_client){
}
//printf("test avant while\n");
int first = 0;
char buf[8000];
while(!feof(fd) && fgets(str,8000,fd) != NULL){
char* resTest = testCorrect(str,first);
char* resTest = testCorrect(str,first, buf);
if(resTest!=NULL)fprintf(fd,"<Notre Serveur> %s\n",resTest);
first=1;
fflush(fd);
......
No preview for this file type
socket.o: socket.c socket.h client.h
client.o: client.c socket.h client.h
main.o: main.c socket.h
socket.o: socket.c socket.h client.h
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment