0

I am currently working on the server pset however my server doesn't load the files even if the status printed in the terminal is 200. Also if I refresh the page it will be changed to 404. Can someone help me please?

Terminal Outputs

1

I have many takes on your code which you posted here, but I'm gonna answer your question specifically. what's causing this weird behavior is that you're using

strcat(root, rq);

per strcat's man page:

char *strcat(char *dest, const char *src);

The strcat() function appends the src string to the dest string, over‐writing the terminating null byte ('\0') at the end of dest, and then adds a terminating null byte.

so you're changing the value of root which causes things to crash.

3
  • Thank you! That does fix the reloading problem however I still cannot load the files:( Sep 29 '15 at 15:40
  • @FlorenceWu you should probably use gdb and try figuring out what you're doing wrong.
    – kzidane
    Sep 29 '15 at 20:23
  • If it cannot load the files then it is probably something wrong with the respond to client part... consider dprintf and write without the if conditions... and the instructions are a bit vague... the extra CRLF is at supposed to be at the very end of 'content type' Oct 16 '15 at 14:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .