Hello, I've been working on Pset6, which requires implementation of four functions on previously writen code. Apparently, as by manually testing, it should pass every test on check50, but that's not the case once check50 runs.
These are the tests I'm failing:
:( Requesting cat2.HTML returns 200, text/html, and correct file
:( Requesting cat3.HtMl returns 200, text/html, and correct file
:( Requesting cat.gif returns 200, image/gif, and correct file
:( Requesting test.js returns 200, text/javascript, and correct file
:( Requesting hello.php? returns 200, text/html, and correct output \ expected output, not an exit code of 0
:( Requesting /test/ outputs /test/index.html
For the first two tests I created files with those names to check if the problem was with my code not properly handling capital letters on the file extension, that was not the case, files with capitals in their extensions were loaded properly. For the .gif image and .js javascript I did not run manual tests. Requesting hello.php? manually returns the exact same thing as requesting hello.php. I'm not sure what "expected output, but not an exit code of 0" means. Finally, manually requesting /test/ does indeed return /test/index.html which is actually just a video called RickRolle'D.
Here are my four functions:
Code removed
Any suggestions on why I might be failing these tests on the check50 app would be greatly appreciated.
bytes
should (almost) always be 2 because you are always reading 2 bytes herefread(buffer, 2, 1, file);
. Why, then, are you doingbytes * 2
in so many places? Also, just like all the other psets, thiswhile ( !feof(file) )
is not the proper way to detect end-of-file. You do the one extra read thing and bugs ensue. I think you need to put in more time on load, then either edit the question appropriately, or better still, write the answer : ) Thisexpected output, not an exit code of 0
generally indicates a seg fault. Testhello.php?
with a curl request, because browsers drop the ?.fread(buffer,1,512,file)
might do the trick. check50 could be failing on files with an odd length (hello.php is 281 bytes), because your length is always even. (Although seg fault is still indicated for /hello.php?). If this gets you back on track, be sure to write an answer. You'll be able to accept it in 2 days.