I am running through the first half of PSET6 and have everything in check50 green other than the cat.exe section:

:( Requesting cat.exe returns error code 501 \ expected output, but not "HTTP/1.1 404 Not Found\r\nContent-Type:..."

I am a bit confused as to why check50 expects a return of 404 since that is not one of the spec error codes to throw... I have pasted my code below if you have any ideas. My error catching with the GET sequence I think is correct, this is just hanging me up. Thanks for any help you can offer!


1 Answer 1


The proper way to interpret this check50 error is:

Requesting cat.exe returns error code 501 : the right answer is error code 501

\ expected output, but not "HTTP/1.1 404 Not Found...: server returned a 404

If you read through server from around line 182, you will find the block of code that uses all the assigned functions. Since your server returns 404 when cat.exe is called by check50, and the only 404 in the program comes at line 209 in server, that must be where the error is being produced. But why? Simply put, path is built by concatenating the abs_path that was returned from parse with the document root. You can conclude, therefore, that the abs_path is wrong.

The best tool to discover why abs_path is wrong is gdb. Some tips here. A second choice would be to troubleshoot and debug with printfs. Some tips about that: make sure that main sees abs_path the same way that your parse function does. This format string "%s<-" could prove useful. By putting a "marker" at the end of the string, you'll be sure to know if your string contains any non-printing characters.

  • So I have been adjusting the length of buffer2 to try to ensure that the string that will be copied to abs_path is correct. I was unable to get rid of this result which I guess now means there is something wrong... "/hello.html\367\377" This is still happening even after I set buffer2[11] to '\0' Any ideas why this would still happen? gdb is helping but I guess I need to understand what this even means.
    – Zach B
    Aug 30, 2016 at 18:26
  • As per the posted code: k will be 15 when it finds the space after html and breaks out of the while loop. when will be 0 because there is no '?'. So it will put the null byte in buffer2[15 - 2 - 0], which is the result you are reporting. What /hello.html\367\377 means: when you declared buffer2, program allocated memory at some address. There was already "stuff" in that memory. Since (posted) program did not assign values to buffer2[11] or buffer2[12], that "stuff" remains. Aug 31, 2016 at 12:30
  • thanks for the help! I guesss I got a bit tunnel visioned because I had it as 4 later but each time I was changing it and running it, I forgot to make in between...which of course would cause some issues. thanks again!
    – Zach B
    Aug 31, 2016 at 14:15

You must log in to answer this question.

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