0

I'm having trouble getting the web browser to load the files I'm attempting to access. I know I've correctly identified 'path' and when I pull up the web browser I get the 200 OK response but nothing appears on the screen. I'm thinking the problem lies somewhere in the 'respond to client' todo. Below is my code. Is there something I'm doing wrong here?

dprintf(cfd, "HTTP/1.1 200 OK\r\n");
dprintf(cfd, "Connection: close\r\n");
dprintf(cfd, "Content-Length: %i\r\n", length);
dprintf(cfd, "Content-Type: %s\r\n", type);
write(cfd, body, length);

This problem set is pretty infuriating simply because the hang up I'm dealing with is on the web browser end and there is simply no way for me to debug this through gdb. Please let me know what's wrong before I throw my computer out the window!

1

I figured out my problem. I forget the extra CRLF at the end of content-type as defined in the instructions.

I will also say that the instructions make no mention of the write command for this portion of the code and I was only able to figure it out by watching one of the videos on the instructions page and looking at the PHP portion of the code as well.

2
  • Order of dprintf's also matters here too. I had also previously switch content-length and content-type. – plumsmugler Oct 14 '15 at 13:52
  • Some of the instructions were a bit vague, like it seemed to say to add a second CRLF after "connection: close"... the writing of this set was a bit rushed... I am pretty sure they will update it next time... The actual coding was pretty straightforward even though at first it was almost incomprehensible... – Peter Zhang Oct 16 '15 at 14:07

You must log in to answer this question.

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