0

i think the problem is in indexes.Here is my code:

char* indexes(const char* path)
{
   char* path1 = malloc(sizeof(char) * (strlen(path) + 15));
   strcat(strcpy(path1,path),"/index.html");
   char* path2 = malloc(sizeof(char) * (strlen(path) + 15));
   strcat(strcpy(path1,path),"/index.php");
   if (access(path1,F_OK) != -1)
    return path1;
   else if (access(path2,F_OK) != -1)
   {
       free(path1); 
       return path2;
   }
   else
    free(path2); 
    return NULL;
}
  1. :( Requesting cat.jpg returns 200, image/jpeg, and correct image :(
  2. Requesting cat.gif returns 200, image/gif, and correct file
  3. :( Requesting favicon.ico returns 200, image/x-icon, and correct file
  4. :( Requesting two files in a row (cat.html then cat.jpg) succeeds
4
  • Which test(s) in check50/server 2 give "end of input" error? Re. check50/server1: Did you correct printf("405 method not allowed"); in your parse function? – DinoCoderSaurus Apr 18 '16 at 14:58
  • the printf statement is the same in my code in parse function..u asked me to do that earlier too but i didnt find anything different or wrong in that..And the check50/server2 says end of input ..nd thanks for help :)@DinoCoderSaurus – Aditi Apr 18 '16 at 15:46
  • you should not use a printf to indicate an error in parse. Do it the same way you reported other errors, using a call to error(). There are 15 tests in check50/server2: cat.jpg, cat.html, cat2.HTML, etc. Which one reports "end of input"? – DinoCoderSaurus Apr 18 '16 at 16:05
  • corrected the printf..see that screenshot @DinoCoderSaurus – Aditi Apr 18 '16 at 16:41
1

You are never populating path2. That will cause the "test/index.html" fail. Look carefully at your strcat statements. Also, review the first 5 or so minutes of Week 2 lecture. You are not properly {} your if/else blocks, and that's just a bug waiting to happen (maybe happening already!).

If you are not handling php extension properly in lookup, it would cause the 4 errors that mention php files. Check it carefully.

I suspect you have a bug in load, based on cat.jpg, cat.gif, favicon.ico and two-files-in-a-row fails. Could be that your load handles files smaller than 512 bytes properly (or some threshold), but not files larger.

1
  • just these 4 errors left now...@DinoCoderSaurus – Aditi Apr 18 '16 at 19:48

You must log in to answer this question.

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