I have just finished the 4 functions from Pset 6 (server.c). Well, everything works "fine". If I request /cat.html
it returns HTTP/1.1 200 OK
and if request cat.exe
it returns the most famous server response 404 Not found
. Also if I request cat.jpg
it return the happy cat! And so on... But when I run check50 2015.fall.pset6.server1 server.c
, says that :( Two spaces after GET returns error code
and :( Two spaces before HTTP/1.1 returns error code
if you want to take a look at the output: https://sandbox.cs50.net/checks/8ee5760bad0f44c580b97b9efee6956c. Well I've spent some hours trying to debug it, trying to find out what does that errors mean, but I think it's time to ask for help! I think that the problem may rely on my parse function. My parse function:
Am I touching memory that is not supposed to be accesed? Am I properly null-terminate string? I've tried different approaches but with no success so far. Thank you very much for your help. Greetings.
1 Answer
Your program may work properly, however it doesn't adhere to the specs. As per the RFC document cited in the pset instructions (emphasis added):
A request-line begins with a method token, followed by a single space (SP), the request-target, another single space (SP), the protocol version, and ends with CRLF.
According to man strtok:
... a sequence of two or more contiguous delimiter bytes in the parsed string is considered to be a single delimiter,
Those two factors are at the heart of the check50 failures.
-
1Thank you very much, indeed I was not adhering to the specs of tools.ietf.org/html/rfc7230#section-3.1.1 I checked for the single spaces and voila! Thank you so much. May 4, 2016 at 4:33