Lots of things going on here. It is definitely a good investment of time to learn how to use gdb (tips here) or debug50 to help troubleshoot server.
To start with, there is no
return true; in this parse. Anything that does not fail one of the earlier tests will always give a 501 error and return false. That is part of the problem with the "non-existAnt file" test. There is no "file not found" test in parse, that is taken care of in another part of server. Read the server code from around line 185 (where parse is called) to get an idea how that works.
Once you fix that problem, there will still be problems with the "non-existant file" test. First review this part of the specification where it defines what a request-line and request-target look like.
Per 3.1.1 of http://tools.ietf.org/html/rfc7230, a request-line is defined as
method SP request-target SP HTTP-version CRLF
wherein SP represents a single space ( ) and CRLF represents \r\n. None of method, request-target, and HTTP-version, meanwhile, may contain SP.
Per 5.3 of the same RFC, request-target, meanwhile, can take several forms, the only one of which your server needs to support is
absolute-path [ "?" query ]
whereby absolute-path (which will not contain ?) must start with / and might optionally be followed by a ? followed by a query, which may not contain ".
These two lines
char* requestPath = strchr(line, forwardSlash); and
strcpy(abs_path,requestPath); do not conform to the definition of abs_path. If the request-line is "GET /hello.html HTTP/1.1\r\n", then what will this
strchr(line, forwardSlash) return? The routines to build abs_path and query need more work. (I'll say it again: gdb).
The failure of "GETabc" is here:
// Check if the request method is GET
char* method = strstr(line,"GET");
if (strncmp(line, method,sizeof(3)) != 0 )
One problem with this
sizeof(3). 3 is an integer, size of an integer is 4 or 8 depending on architecture. You probably meant 3.
Another problem: What will this
strncmp(line, method,sizeof(3)) evaluate to if line includes "GETabc"? (and assuming the sizeof(3) is corrected). It will be true. What if you consider the first SP in request-line as part of method when writing the test?
This is just some low-hanging fruit. There could certainly be other problems either introduced by corrections or uncovered by corrections. Keep at it and you will have success.