This is my coursework. It is test a web server written in C++ code. It must be concurrent server using Posix threads. I have got skeleton server programe already given to me (Everyone gets that). That works perfectly. I am using linux to test and write the code.
I need to add in code to indentify the extensions:
.htm .html .jpg .jepg .txt
I have written code for .jpg only before I do rest of it as soon I know it works. I was wondering how you test it? It should work cos I have copied most of that code. I know how to test other parts of code like if GET or POST request. I test it this way:
I got file called:
test-ok.tst
in that file got:
GET /little.html HTTP/1.0
Connection: close
I also got html file called little.html.
My code file is called server.cpp. To test it I type in command line:
g++ server.cpp -lpthread
Then in new line:
./a.out 8123
Then in another command line window:
nc localhost 8123 < test-ok.tst
That test doesn't work for that bit of code cos there no .jpg to test. So where do I put .jpg to test if it works?
const char *ext=strrchr(filename,'.');
if(ext!=0 && strcmp(ext,".jpg")==0)
{
const char *reply="extension is .jpg\n";
write(1,reply,strlen(reply));
}