Skip to content
Snippets Groups Projects
Commit a9c571bf authored by Romain Gabet's avatar Romain Gabet :speech_balloon:
Browse files

ok o ok

parent a279f36e
No related branches found
No related tags found
No related merge requests found
File deleted
......@@ -9,16 +9,18 @@
char* testCorrect(char* str){
char* testCorrect(char* str, int first){
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";
if(strstr(str,correctStr) == NULL && !strcmp(str,"\r\n")){
if(strstr(str,correctStr) == NULL && first == 0) {
strRet=incorrectStr;
//printf("---\n%s\n---",str);
}else{
}else if(!strcmp(str,"\r\n")) {
strRet = correctStr2;
}else{
strRet = NULL;
}
printf("---\n%s\n---",strRet);
return strRet;
......@@ -41,12 +43,15 @@ int traitementClient(int socket_client){
exit(1);
}
//printf("test avant while\n");
while(!feof(fd) && fgets(str,8000,fd) != NULL){ /* writing content to stdout */
fprintf(fd,"<Notre Serveur> %s\n",testCorrect(str));
int first = 0;
while(!feof(fd) && fgets(str,8000,fd) != NULL){
char* resTest = testCorrect(str,first);
if(resTest!=NULL)fprintf(fd,"<Notre Serveur> %s\n",resTest);
first=1;
fflush(fd);
}
first=0;
//fflush(fd);
fclose(fd);
return 0;
}
\ No newline at end of file
}
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.
Finish editing this message first!
Please register or to comment