PSET6 is a huge challenge. I have juste passed the first checked and I am trying to understand why my load function is not 100% correct.
This is the feedback of the second check :
~/workspace/pset6/ $ check50 2015.fall.pset6.server2 server.c
:) server.c exists
:) server compiles
:( Requesting cat.jpg returns 200, image/jpeg, and correct image
:) Requesting cat.html returns 200, text/html, and correct file // HERE !
:) 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 favicon.ico returns 200, image/x-icon, and correct file
:) Requesting test.css returns 200, text/css, and correct file
:) Requesting test.js returns 200, text/javascript, and correct file
:) Requesting hello.php returns 200, text/html, and correct output
:) Requesting hello.php? returns 200, text/html, and correct output
:) Requesting hello.php?name=Alice returns 200, text/html, and correct output
:) Requesting /test redirects to /test/
:( Requesting /test/ outputs /test/index.html
:( Requesting directory containing index.php outputs index.php
\ expected output, but not "HTTP/1.1 200 OK\r\nContent-Type: text/h..."
:( Requesting two files in a row (cat.html then cat.jpg) succeeds
https://sandbox.cs50.net/checks/29f2dd8998ee4890affefbb924170391
This is the code of load. Please notice that I did not code indexes.
bool load(FILE* file, BYTE** content, size_t* length)
{
BYTE buffer[BYTES];
size_t size = 0;
*content = malloc(BYTES);
int ret = fread(buffer, 1, BYTES, file);
size = size+ret;
while(ret > 0) {
memcpy(*content, buffer, ret);
ret = fread(buffer, 1, BYTES, file);
size = size+ret;
*content = realloc(*content, size+1);
}
length = size;
if (*content == NULL) {
return false; }
return true;
}
Is it something with the pointers? My lookup function works fine as well.